Skip to content

Conversation

@trambui09
Copy link

@trambui09 trambui09 commented Jun 13, 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 which is described by the methods it has and how they perform.
Describe a Stack Stack is a ADT, follows the LIFO(last-in-first-out) convention. Some supported functions include popping from the stack which removes the last item that was put in
What are the 5 methods in Stack and what does each do? push - push onto the stack, pop - remove the top item from the stack, is_empty? - checks whether the stack is empty or not, peek - sees, but not remove the item on top, size - returns the size of the stack
Describe a Queue A ADT that follows FIFO convention, First in is the first out
What are the 5 methods in Queue and what does each do? enqueue - put item into the queue, dequeue - remove item from the queue, is_empty? - checks if the queue is empty or not, peek - sees, but not remove the first item in the queue, size - returns the size of the queue
What is the difference between implementing something and using something? Implementing is constructing the methods to use. Using something would be to call the methods we implemented and reuse the implementation code every time we call 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.

Nice work Tram, you hit the learning goals here. Well done.

Comment on lines +3 to 5
# Time Complexity: O(n) - has to iterate through each char in the string input
# Space Complexity: O(n) - the stack is directly correlated with the string.length
def balanced(string)

Choose a reason for hiding this comment

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

👍

@rear = -1
end

def enqueue(element)

Choose a reason for hiding this comment

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

👍


end

def dequeue

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