Skip to content

Conversation

@yesentorres
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? An Abstract Data Type. It is called abstract because the details of its implementation are hidden from whoever is using it.
Describe a Stack A type of ADT where the first element added will always be the last element removed and the most recent element added will be the first removed (LIFO).
What are the 5 methods in Stack and what does each do? push - adds an element, pop - removes an element, empty? - checks if Stack is empty, to_s - returns Stack as a String
Describe a Queue A type of ADT where the first element added will be the first element removed (FIFO).
What are the 5 methods in Queue and what does each do? enqueue - adds an element, dequeue - removes an element, front - returns element at the front of the queue, empty? - checks if Queue is empty, to_s - returns Queue as a String
What is the difference between implementing something and using something? Implementation requires involvement in the process of designing & creating something, whereas using is more concerned with knowing how to apply the thing.

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 Yesenia, you hit all the learning goals here. Well done. Thanks for getting this in.

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.

👍 Nice work!

@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
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 empty?

Choose a reason for hiding this comment

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

👍

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