-
Notifications
You must be signed in to change notification settings - Fork 42
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
Angela #7
base: master
Are you sure you want to change the base?
Angela #7
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.
You don't have the postfix problem done, but overall not bad. You do have some issues with the circular buffer. Take a look at my comments and let me know if you have questions.
@@ -1,7 +1,25 @@ | |||
require_relative './stack.rb' | |||
|
|||
def balanced(string) | |||
raise NotImplementedError, "Not implemented yet" | |||
return false if string.length % 2 != 0 |
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.
👍
def dequeue # remove from front | ||
removed = @store[@front] | ||
@store[@front] = nil | ||
self.size == 0 ? @front = -1 : @front += 1 |
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.
What about the front wrapping around the array. Instead of @front +=1
you should have @front = (@front + 1) % QUEUE_SIZE
end | ||
|
||
def size | ||
raise NotImplementedError, "Not yet implemented" | ||
size = 0 | ||
@store.each do |val| |
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 is less efficient than starting at @front
and progressing through the array until you reach @rear
, or keeping an instance variable for size.
return @store.to_s | ||
def to_string | ||
formatted_array = [] | ||
@store.each do |x| |
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 assumes @front < @rear
, that's not always going to be true.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation