-
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
Kristina - Leaves #45
base: master
Are you sure you want to change the base?
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.
Stack is working fine, but you have some issues with Queue. Take a look at my comments and let me know what questions you have.
# 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.
The method works, time and space complexity?
end | ||
|
||
if @front == @back | ||
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.
end | |
if @front == @back | |
end | |
elsif @front == @back | |
# Raise an error if the Queue is full | |
end |
end | ||
|
||
def dequeue | ||
raise NotImplementedError, "Not yet implemented" | ||
if @front == @back | ||
return "queue is empty" |
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.
It would be better to raise an error in this circumstance.
data = @store[@front] | ||
@store[@front] = nil | ||
|
||
if @front == @back |
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.
I think you need to advance front before comparing it to back.
if @front == @back | ||
return true | ||
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.
if @front == @back | |
return true | |
end | |
return @front == @back |
end | ||
|
||
def to_s | ||
@store.delete(nil) |
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 will shrink the internal array. It's both an expensive operation and it will also not maintain the order of elements in the Queue.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions