-
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
Branches - Brianna #36
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.
Nice work, you hit the main learning goals here. There are some issues with the Queue class. Take a look at my comments and let me know any questions you have.
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(n) - n is chars in string | ||
# Space Complexity: O(1/2n) --> O(n) - n is chars in string | ||
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.
👍
# Time Complexity: ? | ||
# Space Complexity: ? | ||
def evaluate_postfix(postfix_expression) |
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 enqueue(element) | ||
raise NotImplementedError, "Not yet implemented" | ||
if((@front == 0 && @back == @store.length - 1) || (@front == @back + 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.
It might be better to use `@front == (@back + 1) % @store.length
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.
👍
raise ArgumentError | ||
end | ||
|
||
return @back - @front |
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 == -1 && @back == -1 | ||
return true | ||
else | ||
return false | ||
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 == -1 && @back == -1 | |
return true | |
else | |
return false | |
end | |
return @front == -1 && @back == -1 |
def to_s | ||
return @store.to_s | ||
return @store[@front...@back].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.
Again this only works if front < back.
# q = Queue.new | ||
# q.enqueue(0) | ||
# q.enqueue(1) | ||
# q.enqueue(2) | ||
# q.enqueue(3) | ||
# p q | ||
# p q.size | ||
# p q.dequeue | ||
# p q.size | ||
# p q.front |
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 should probably be removed before submission
# q = Queue.new | |
# q.enqueue(0) | |
# q.enqueue(1) | |
# q.enqueue(2) | |
# q.enqueue(3) | |
# p q | |
# p q.size | |
# p q.dequeue | |
# p q.size | |
# p q.front |
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation