Skip to content

Conversation

@halahaddad1
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 (ADT), is a type of object which is described by the methods it has and how they perform, meaning the behavior of the method is abstracted, and the user is only concerned with the use or implementation of the method.
Describe a Stack A Stack is an Abstract Data Structure which stores data and allows access in a Last-In-First-Out order (LIFO). A stack looks like a cafeteria tray stack, first tray in first out
What are the 5 methods in Stack and what does each do? 1- initialize = creates a new stack, 2- push = adds an element to the beginning of the Stack, 3- pop = removed first element of the stack (the one that was added last), 4- empty? = checks if stack is empty, 5- to_s = prints the stack out to the cli as an array
Describe a Queue A Queue is an Abstract Data Structure which stores data and allows access in a First-In-First-Out order (FIFO). A Queue is the line at the Supermarket, whoever stands in line first gets served first.
What are the 5 methods in Queue and what does each do? 1- initialize = creates a new queue, 2- enqueue = adds an element to the end of the queue, 3- dequeue = removed first element of the queue (the one that was added first), 4- empty? = checks if queue is empty, 5- to_s = prints the queue out to the cli as an array.
What is the difference between implementing something and using something? Implementing something means finding a solution to something, using something means using the solution from the Implementation.

OPTIONAL JobSimulation

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

@halahaddad1 halahaddad1 changed the title all tests passing Space - Hala 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.

You didn't implement the Queue with a circular buffer. Other than that major piece you hit all the learning goals.

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.

👍

Comment on lines +12 to +18
if char == ']' && element != '['
return false
elsif char == ')' && element != '('
return false
elsif char == '}' && element != '{'
return false
end

Choose a reason for hiding this comment

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

This could be dried up using a hash with keys being the open brace and the value being the corresponding close brace.

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.

👍

@@ -1,31 +1,36 @@
require_relative "linked_list"

class Queue

Choose a reason for hiding this comment

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

This works, but isn't implemented with a circular buffer. So it's not what's asked for.

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