Skip to content

Conversation

@beauttie
Copy link

@beauttie beauttie commented Apr 14, 2021

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? An Abstract Data Type is a type of object described by its methods and their performance/behavior.
Describe a Stack A stack is a data structure that stores a list of data and provides access to it in Last-In-First-Out order.
What are the 5 methods in Stack and what does each do? Push puts an item on top of the stack, pop removes and returns the item on top of the stack, peek returns but does not remove the item on top of the stack, size returns the number of items in the stack, and empty? returns a boolean indicating if the stack is empty or not.
Describe a Queue A queue is also a data structure that stores a list of data but provides access to it in First-In-First-Out order.
What are the 5 methods in Queue and what does each do? Enqueue puts an item to the back of the queue, dequeue removes and returns the item at the front of the queue, front only returns the first item in the queue, size return the number of items in the queue, and empty? returns a boolean indicating if the queue is empty or not.
What is the difference between implementing something and using something? Using something doesn't require you to know how to implement it.

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.

This is really well done Beauttie. Great work!

Comment on lines +3 to 5
# Time Complexity: O(n)
# Space Complexity: O(n)
def balanced(string)

Choose a reason for hiding this comment

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

👍

Comment on lines +24 to 26
# Time Complexity: O(n)
# Space Complexity: O(n)
def evaluate_postfix(postfix_expression)

Choose a reason for hiding this comment

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

👍

end
end

def dequeue

Choose a reason for hiding this comment

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

👍

return @store[@front]
end

def size

Choose a reason for hiding this comment

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

👍 nice and compact

return @front == @back
end

def full?

Choose a reason for hiding this comment

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

👍

return @front == (@back + 1) % ARRAY_SIZE
end

def to_s

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