-
Notifications
You must be signed in to change notification settings - Fork 42
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
Erica #18
base: master
Are you sure you want to change the base?
Erica #18
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.
Not bad, you hit most of the learning goals. In particular see my notes on your Stack implementation. Let me know if you have questions.
else | ||
dequeued = @store[@front] | ||
@store[@front] = nil | ||
@front = (@front + 1) % QUEUE_SIZE |
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.
You should also check to see if the queue is now empty.
end | ||
|
||
def empty? | ||
raise NotImplementedError, "Not yet implemented" | ||
queue = @store.compact |
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.
This is a pretty expensive way to see if the queue is empty.
Why not just return @front == -1
?
end | ||
|
||
def size | ||
raise NotImplementedError, "Not yet implemented" | ||
return @store.compact.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.
This is a bit expensive. You could also calculate the size based on the locations of front and rear.
end | ||
|
||
def push(element) | ||
raise NotImplementedError, "Not yet implemented" | ||
if @front == -1 |
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.
You don't really need a circular buffer for a Stack as you only add or remove on one end (the top). Instead I'd asked you to use a Linked List. So this is a little weird.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation