Leaves-Yasmin#27
Open
YasminM11 wants to merge 1 commit into
Open
Conversation
CheezItMan
reviewed
Mar 10, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work. One minor issue with the Queue, but otherwise excellent job. Take a look at my comments and let me know if you have questions.
| # @back = -1 | ||
| end | ||
|
|
||
| def enqueue(element) |
Comment on lines
+32
to
+34
| if element = @store[@front] | ||
| @front = (@front + 1) % @store.length | ||
| return element |
There was a problem hiding this comment.
The problem here is determining if the queue is empty or full because in either case front would be equal to back.
So
Suggested change
| if element = @store[@front] | |
| @front = (@front + 1) % @store.length | |
| return element | |
| if element = @store[@front] | |
| @front = (@front + 1) % @store.length | |
| @front = @back = -1 if @front == @back | |
| return element |
| def size | ||
| raise NotImplementedError, "Not yet implemented" | ||
| # raise NotImplementedError, "Not yet implemented" | ||
| return @store.length |
There was a problem hiding this comment.
This only gives you the length of the internal storage, not the size of the queue.
Comment on lines
+50
to
+54
| if @front == @back | ||
| return true | ||
| else | ||
| return false | ||
| end |
There was a problem hiding this comment.
Suggested change
| if @front == @back | |
| return true | |
| else | |
| return false | |
| end | |
| return @front == @back |
| end | ||
| end | ||
|
|
||
| def to_s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation