Kristy, Branches#29
Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Some issues with your Queue class. Take a look at my comments and let me know if you have questions. Other than that this works.
| @@ -3,7 +3,25 @@ | |||
| # Time Complexity: ? | |||
| # Space Complexity: ? | |||
| def balanced(string) | |||
| if @front == @back | ||
| #decide | ||
| end |
There was a problem hiding this comment.
This part works better as an elsif to raise an error if the queue is full. You're not doing anything here.
| raise NotImplementedError, "Not yet implemented" | ||
| end | ||
|
|
||
| def dequeue |
There was a problem hiding this comment.
You also need to check if the queue is empty before and after you dequeue an element.
| def size | ||
| raise NotImplementedError, "Not yet implemented" | ||
| return @store.compact.length | ||
| end |
There was a problem hiding this comment.
This works, but it's quite expensive O(n) for both space and time and you lose some of the benefits of the circular buffer.
| def empty? | ||
| raise NotImplementedError, "Not yet implemented" | ||
| @store.compact.empty? ? true : false |
There was a problem hiding this comment.
Why the conditional? Why not just return @store.compact.empty?
Oh and like the previous method, this becomes very expensive.
| def to_s | ||
| return @store.to_s | ||
| return @store.compact.to_s |
There was a problem hiding this comment.
This mostly works, but if back < front, the order of materials in the queue won't be maintained.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation