Leaves - Mariya#38
Open
M-Burr wants to merge 1 commit into
Open
Conversation
CheezItMan
reviewed
Mar 10, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Overall not bad, some minor issues with Queue. Otherwise it's pretty well done. Nice work
Comment on lines
+17
to
+22
| front_array = @store.slice(0, @front) | ||
| back_array = @store.slice(@back, @store.length - 1) | ||
| @store = front_array + Array.new(10) + back_array | ||
| @front = (@front + 10) % @store.length | ||
| end | ||
|
|
There was a problem hiding this comment.
This assumes that front is less than back
Comment on lines
+28
to
+31
| removed = @store[@front] | ||
| @store[@front] = nil | ||
| @front = (@front + 1) % @store.length | ||
| return removed |
There was a problem hiding this comment.
You should also check if the queue is now empty.
Comment on lines
+43
to
+47
| 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 | ||
|
|
||
| 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
| Describe a Stack | an ADT where elements that are last in, are first out |
| What are the 5 methods in Stack and what does each do? |
| Describe a Queue | ADT where first element in is the first element out |
| What are the 5 methods in Queue and what does each do? |
| What is the difference between implementing something and using something? | Implementing is like creating the code/function (e.g., a stack class), but using it requires calling on the implemented code to perform actions. Implementation is the creation of something, which needs to be done prior to using/utilizing that code. |
OPTIONAL JobSimulation