Skip to content

Conversation

@syrosalynyu
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? You need to know how to use it, but has no idea how it works internally. The Abstract Data Type only tells you what operations have been implemented but it wouldn't tell you how these operations were implemented
Describe a Stack It is used to store data and allows access in a Last-In-First-Out order (LIFO)
What are the 5 methods in Stack and what does each do? push() => push a element to the top of the stack; pop() => remove the element from the top of the stack; empty? => to check if the stack is empty or not
Describe a Queue It is used to stores data and allows access in a First-In-First-Out order (FIFO)
What are the 5 methods in Queue and what does each do? enqueue() => push a element to the rear of the queue; dequeue() => remove the element from the front of the queue; empty? => to check if the queue is empty or not;
What is the difference between implementing something and using something? When you use sth, you don't need to know how it was implemented. But when you implement sth, you need to know the logic of 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.

Ross, all the methods work, but you implemented the Queue with a straight array instead of a circular buffer. I suggest you review circular buffers just so you are clear on how they can be implemented.

Comment on lines 3 to 5
# Time Complexity: ?
# Space Complexity: ?
def balanced(string)

Choose a reason for hiding this comment

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

👍 , but time/space complexity?

Comment on lines +7 to +11
pairs = {
"{" => "}",
"(" => ")",
"[" => "]"
}

Choose a reason for hiding this comment

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

Love the use of a hash here.

@max_size = 20
end

def enqueue(element)

Choose a reason for hiding this comment

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

This works, but you have implemented the Queue with a straight array instead of a circular buffer.

@@ -1,19 +1,22 @@
require_relative 'linked_list.rb'

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