-
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, C. Gutierrez #37
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.
Your Queue class does not use a circular buffer. Instead it's using an array with an O(n) dequeue operation. It works, but it's not the assignment. Your Stack class does work and work well.
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
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.
Since you're building expected_mirror
up, this does have some space complexity. It should be O(n) space complexity.
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
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.
This doesn't seem to handle postfix expressions with more than 3 terms.
@back = 0 | ||
# this adds a viable index number, because for this part of the "if" statement, the array is empty, both front and back are 0 | ||
else | ||
@store.push(value) |
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.
Using push will always put an element to the end of the array, there's no way to "wrap" the back around the internal array.
def dequeue | ||
raise NotImplementedError, "Not yet implemented" | ||
|
||
temp = @store[0] | ||
|
||
if @back == 0 | ||
@store.slice!(0) | ||
@front = -1 | ||
@back = -1 | ||
return temp | ||
end | ||
|
||
@back -= 1 | ||
@store.slice!(0) | ||
|
||
return temp |
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 method isn't really using a circular buffer, but instead using an array with the front fixed at index 0.
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation