Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ren - Fire #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Ren - Fire #20

wants to merge 1 commit into from

Conversation

RenCarothers
Copy link

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? Abstract Data Type - describes the actions that the data type can preform, the details of which are hidden from the public user.
Describe a Stack A type of ADT that stores data in LIFO order (last in first out).
What are the 5 methods in Stack and what does each do? Push - adds to the top of the stack; pop - pops off the top element in the stack; is_empty - returns true if empty, top - displays top element without popping; size - returns size of stack (number of elements)
Describe a Queue A type of ADT that stores data in a first in first out order, much like a checkout line in a grocery store.
What are the 5 methods in Queue and what does each do? Enqueue - adds element to the back of the queue; dequeue - removes element from the front of the queue; is_empty - returns true if the queue is empty; front - displays element at the front without dequeuing; size - returns the number of elements in the queue.
What is the difference between implementing something and using something? In the case of ADTs, using one doesn't require that you know how to implement it, for instance, someone might utilize a queue in their code without knowing how the queue works behind the scenes.

OPTIONAL JobSimulation

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

Copy link

@CheezItMan CheezItMan 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 Ren, this hits all the learning goals. I had a few comments on the Queue class, but otherwise this is quite well done.

Comment on lines +18 to +20
else # otherwise, ok to add
@back += 1
end

Choose a reason for hiding this comment

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

I think you need to do @back += 1 after the @store[@back] = element because otherwise you could add 1 element and front = back = 0 and then self.empty? would still be true.

@back += 1
end

@store[@back] = element # in any non exception case, add element to queue
end

def dequeue

Choose a reason for hiding this comment

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

👍

Comment on lines 50 to 54
def size
raise NotImplementedError, "Not yet implemented"
return 0 if @store.empty?

return (@front - @back).abs + 1
end

Choose a reason for hiding this comment

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

⚠️ I don't think this works in all cases

@@ -1,19 +1,22 @@
class Stack

Choose a reason for hiding this comment

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

👍

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