Skip to content

Faiza#22

Open
Faiza1987 wants to merge 6 commits intoAda-C11:masterfrom
Faiza1987:master
Open

Faiza#22
Faiza1987 wants to merge 6 commits intoAda-C11:masterfrom
Faiza1987:master

Conversation

@Faiza1987
Copy link
Copy Markdown

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
Copy Markdown

@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.

Some issues here with the circular buffer, but overall this is pretty good. Take a look at my comments and let me know where you have questions.

Comment thread lib/problems.rb
"{" => "}",
}

stack = Stack.new
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nicely done

Comment thread lib/queue.rb
if @front == -1 # Q is empty
return

elsif @front == @rear # There's only 1 element
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When front and rear are equal, the Queue is not empty, it's full.

When they're equal after removing an element, then the queue is empty.

Comment thread lib/queue.rb
array = []
@store.each_with_index do |element, i|
next if i < @front
break if element.nil?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What if you've removed 1 element from the front of the queue. Then @store[0] will be nil, and you'll exit the loop early here.

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