-
Notifications
You must be signed in to change notification settings - Fork 64
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
Rock: Libby Gerber #47
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 Libby, you hit the learning goals here. Well done.
# Time Complexity: O(log n) | ||
# Space Complexity: O(1) | ||
def add_helper(self, current, key, 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.
👍 Since this is recursive the space complexity is O(log n) assuming the tree is balanced and O(n) otherwise.
# Time Complexity: O(log n) | ||
# Space Complexity: O(1) | ||
def find(self, key): |
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: O(n) | ||
# Space Complexity: O(1) | ||
|
||
# Time Complexity: | ||
# Space Complexity: | ||
def inorder_helper(self, current, values_list): |
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.
👍 , but since you're building a list of node values, the space complexity is O(n)
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
|
||
def preorder_helper(self, current_node, values_list): |
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.
👍 Same issue with space complexity
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def postorder_helper(self, current_node, values_list): |
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.
👍 Same issue with space complexity
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def height_helper(self, current_node): |
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 the tree is balanced this is O(log n) for space complexity and O(n) otherwise.
No description provided.