Skip to content

Roza-Cedar, re-submission including comprehension questions#38

Open
haset-19 wants to merge 1 commit intoAda-C16:masterfrom
haset-19:master
Open

Roza-Cedar, re-submission including comprehension questions#38
haset-19 wants to merge 1 commit intoAda-C16:masterfrom
haset-19:master

Conversation

@haset-19
Copy link
Copy Markdown

Stacks and Queues

Thanks for doing some brain yoga. You are now submitting this assignment!

Comprehension Questions

Question Answer
What is an ADT? is a type of object which is described by the methods it has and how they perform. Implementation details are not included
Describe a Stack Is a data structure that stores lists of data but those data can be accessed through last in-first out
What are the 5 methods in Stack and what does each do? size, to return the total elements in a stack, is_empty to check if the stack is empty, pop to remove and return the element on top of the stack, push to insert element on the top, peek, to return top element but not doesn't remove
Describe a Queue is an abstract data structure to store a list of elements like stack but allows access only in first come first out
What are the 5 methods in Queue and what does each do? enqueue to add element at the end, dequeue to remove element from the front, is_empty, to check if the queue is empty, size to calculate the total elements and return
What is the difference between implementing something and using something? Implementing something the way the implementer prefers and abstracting the details, the data structures used etc, and the user doesn't have to know the details.

OPTIONAL JobSimulation

Question Answer
Did you include a sample run of your code as a comment?

Copy link
Copy Markdown

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨💫 Nice work! I left a couple of suggestions. Great job on the comprehension questions. Let me know what questions you have.

🟢

Comment thread stacks_queues/queue.py
returns None
"""
pass
if self.size == self.buffer_size:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/queue.py
The Queue is empty.
"""
pass
if self.empty():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/queue.py
is empty. Does not remove anything.
"""
pass
return self.store[self.front]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/queue.py
The Queue
"""
pass
return self.size
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/queue.py
And False otherwise.
"""
pass
return self.front == self.rear
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 This will check if the queue is empty, but it could also mean the queue

Comment thread stacks_queues/queue.py
Comment on lines +86 to +88
while (start_index % INITIAL_QUEUE_SIZE) < INITIAL_QUEUE_SIZE and len(queue_list) < self.size:
if self.store[start_index % INITIAL_QUEUE_SIZE] is not None:
queue_list.append(self.store[start_index % INITIAL_QUEUE_SIZE])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using self.buffer_size instead of the constants for style reasons. It will also allow us to expand our queue functionality in the future, say if we wanted to increase buffer_size instead of just raising an error.

Suggested change
while (start_index % INITIAL_QUEUE_SIZE) < INITIAL_QUEUE_SIZE and len(queue_list) < self.size:
if self.store[start_index % INITIAL_QUEUE_SIZE] is not None:
queue_list.append(self.store[start_index % INITIAL_QUEUE_SIZE])
while (start_index % self.buffer_size) < self.buffer_size and len(queue_list) < self.size:
if self.store[start_index % self.buffer_size] is not None:
queue_list.append(self.store[start_index % self.buffer_size])

Comment thread stacks_queues/stack.py
"""
pass

self.store.add_first(element)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/stack.py
"""
pass

return self.store.remove_first()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/stack.py
And False otherwise
"""
pass
return self.store.empty()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread stacks_queues/stack.py
pass
return self.store.empty()

def __str__(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ This works, but you might also consider taking advantage of LinkedList's str() method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants