Skip to content

Conversation

@shubha-rajan
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 ADT is an Abstract Data Structure
Describe a Stack An abstract data type with a LIFO structure
What are the 5 methods in Stack and what does each do? push: add to stack, pop: remove from stack, peek: return top of stack without removing it, size: number of items in stack, empty: whether stack is empty
Describe a Queue An abstract data type with a FIFO structure
What are the 5 methods in Queue and what does each do? enqueue: add to queue, dequeue: remove from queue, front: return front of queue without removing it, size: number of items in queue, empty: whether queue is empty
What is the difference between implementing something and using something? Implementing something is creating the interface to use it, writing methods, etc. Using it is creating an instance and calling methods.

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.

Thanks for getting this in. Well done! You hit all the learning goals here.

@@ -1,9 +1,41 @@
require_relative './stack.rb'

def balanced(string)

Choose a reason for hiding this comment

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

👍

stack.empty? ? (return true) : (return false)
end

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.

👍

Comment on lines +31 to +39
if (@head == @tail && !empty?)
return @capacity
elsif @head == @tail
return 0
elsif @tail > @head
return @tail - @head
elsif @tail < @head
return @capacity - (@head - @tail)
end

Choose a reason for hiding this comment

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

Nice! 🥇

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