Skip to content

Conversation

@GeMath18
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? Stands for Abstract Data Type. It 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 A Stack is a data structure which stores a list of data and only provides access in a Last-In-First-Out (LIFO) order.
What are the 5 methods in Stack and what does each do? A Stack provides the following methods:(1) push(item) - This method puts an item into the stack at the top. (2) pop - This method removes and returns the item on the top of the stack.(3)is_empty - This method returns true if the stack is empty and false otherwise.(4) peek method - which returns, but does not remove the item on top of the stack, and (5) size- which would return the number of items on the stack.
Describe a Queue A queue is a data structure unlike a stack operates in a first-in-first out order.
What are the 5 methods in Queue and what does each do? A Queue provides the following methods:(1)enqueue(item) - This method puts an item into the back of the queue.(2)dequeue - This method removes and returns the item at the front of the queue.(3)is_empty - This method returns true if the queue is empty and false otherwise.(4)front - returns the first element of the queue without removing it (5)size - returns the number of elements in the queue
What is the difference between implementing something and using something? When you use something it doesn't necessarily mean you require to know how it was implemented

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 Gessica, you hit the learning goals here. Well done.

Comment on lines +4 to 6
# 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.

👍 I love the use of the hash here!

@store[@rear] = element
end

def dequeue

Choose a reason for hiding this comment

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

👍

@@ -1,19 +1,25 @@
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