-
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
Kristy, Branches #29
base: master
Are you sure you want to change the base?
Kristy, Branches #29
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.
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) |
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.
👍
if @front == @back | ||
#decide | ||
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.
This part works better as an elsif to raise an error if the queue is full. You're not doing anything here.
end | ||
|
||
def dequeue |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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