Skip to content

Conversation

@TaylorMililani
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? Abstract data type
Describe a Stack a collection of elements where the last element to be added will be the first to be removed (LIFO)
What are the 5 methods in Stack and what does each do? push adds an element to the top of the stack, pop removes the top element, empty checks if the stack is empty, full? checks if stack is full, peek gets element at top of stack without returning it.
Describe a Queue a collection where the first element added will be the first to be removed. (FIFO)
What are the 5 methods in Queue and what does each do? Enqueue adds an element to the queue, dequeue removes and returns an element, peek gets the element at the front without returning it, full? - checks if queue is full, empty? - checks if queue is empty
What is the difference between implementing something and using something? implementing means to create it, using it puts it into practice.

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

Comment on lines +3 to 5
# Time Complexity: O(nlogn)
# 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.

Since you have to go through all the chars and you're not splitting at each stage, this is O(n) for time complexity.

Comment on lines +10 to +12
if chars.include?(char)
stack.push(char)
else

Choose a reason for hiding this comment

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

Could you do this with a hash where the keys are the open brace and he values are the matching close brace? That might help you dry up those if-else statements.

Comment on lines +26 to 28
# 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.

👍 Interesting use of eval

(@end + 1) % @size == @start
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.

👍

@@ -1,31 +1,65 @@
class Queue

Choose a reason for hiding this comment

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

👍 Well done!

@@ -1,22 +1,24 @@
require_relative 'linked_list'

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