Skip to content

Conversation

@wangjoc
Copy link

@wangjoc wangjoc commented Sep 9, 2020

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT? A type of object which is described by the methods it has and how they perform.
Describe a Stack Stack is an ordered collection of items where items are added to and removed from the end (top). Follows LIFO.
What are the 5 methods in Stack and what does each do? Push (adds new items, returns nothing), pop (removes top item, returns the item), peek (returns top item, but does not remove it), isEmpty (tests to see if stack is empty, returns boolean), size (returns number of items in stack, returns integer).
Describe a Queue Follows FIFO. Used when you want things to happen in the order that they were called.
What are the 5 methods in Queue and what does each do? Enqueue (puts item onto back of the queue), dequeue (removes and returns the item at the front of the queue), is_empty (checks whether a queue is empty and false if otherwise), front (return front of queue), size (return how many elements are in queue)
What is the difference between implementing something and using something? Implementing requires a lot more knowledge because you need to create it; using you only need to know how it works to get the outcome you want.

OPTIONAL JobSimulation

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

@wangjoc wangjoc changed the title completed wave 1, 2, and 3 Time - Jocelyn Sep 9, 2020
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.

Jocelyn, nice work! You hit the learning goals here. Let me know what questions you have.

Comment on lines +3 to 5
# Time Complexity: O(n)
# Space Complexity: O(1)
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 +25 to 27
# Time Complexity: O(n)
# Space Complexity: O(1)
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.

👍 , Nice work, although your space complexity is O(n) since you are building a stack.

return @queue[@front]
end

def size

Choose a reason for hiding this comment

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

Why not just use the positions of front and back to calculate the size instead of this O(n) operation.

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