-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branches - Julia Bouvier #31
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall not bad, some minor issues with your Queue class. Take a look at my comments and let me know any questions you have.
# @store = ... | ||
raise NotImplementedError, "Not yet implemented" | ||
@store = Array.new(30) | ||
@front = @back = -1 | ||
end | ||
|
||
def enqueue(element) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
temp = @store[@front] | ||
@store[@front] = nil | ||
@front = (@front + 1) % @store.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point you also need to check to see if @front == @back
and if so, the queue is empty now and you need to reset them to -1.
if @back.length > @front.length | ||
return @back.length - @front.length | ||
else | ||
return @front.length - @back.length | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back and front are numbers, how would they have lengths?
end | ||
|
||
def empty? | ||
raise NotImplementedError, "Not yet implemented" | ||
@front == @back? true : false | ||
end | ||
|
||
def to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation