Skip to content

Conversation

@bonara
Copy link

@bonara bonara commented Sep 15, 2019

Stacks and Queues

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

Comprehension Questions

Question Answer
What is an ADT?
Describe a Stack
What are the 5 methods in Stack and what does each do?
Describe a Queue
What are the 5 methods in Queue and what does each do?
What is the difference between implementing something and using something?

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.

Overall nice work. There are some issues with the Queue and the circular buffer. Take a look at my notes and let me know what questions you have.

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

👍


def dequeue
raise NotImplementedError, "Not yet implemented"
if @front == @rear

Choose a reason for hiding this comment

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

You first need to check to see if front and rear are both -1, if so, then the queue is empty, and you should raise an error.

Otherwise if front == rear then the queue is full.


def empty?
raise NotImplementedError, "Not yet implemented"
if @store[@front...@rear].length == 0

Choose a reason for hiding this comment

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

What if the rear has wrapped around the buffer and is now less than the front?

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