-
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
Scissors - Aida R. #50
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.
Well done Aida! You hit the learning goals here. Well done. Nice work getting BFS working.
elif current_node.key < key: | ||
current_node.right = self.add_helper(current_node.right, key, value) | ||
return current_node | ||
|
||
def add(self, key, value = None): |
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 recursive solution!
# Time Complexity: O(log n) if Balanced BST and O(n) for Unbalanced BST | ||
# Space Complexity: O(log n) if Balanced BST and O(1) for Unbalanced BST | ||
def find_helper(self, current, 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) where n is each visited node | ||
# Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
# Inorder Traversal: Left - Root - Right | ||
def inorder_helper(self, current, ascending_nodes): |
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 making a list of all the nodes the space complexity is O(n)
# Time Complexity: O(n) where n is each visited node | ||
# Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
# Preoder traversal: Root - Left - Right | ||
def preorder_helper(self, current, preorder_nodes): |
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 making a list of all the nodes the space complexity is O(n)
# Time Complexity: O(n) where n is each visited node | ||
# Space Complexity: O(n) - O(h) for the call stack, where h is the height of the tree | ||
# Postorder traversal: Left - Right - Root | ||
def postorder_helper(self, current, postorder_nodes): |
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 making a list of all the nodes the space complexity is O(n)
# Time Complexity: O(log n) if Balanced BST and O(n) for Unbalanced BST | ||
# Space Complexity: O(n) where n is the number of nodes in a given binary tree. | ||
def height_helper(self, current, current_height): |
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 space complexity is correct if the tree could be unbalanced. If the tree is balanced it's O( log n )
# # Time Complexity: O(n) where n is the number of nodes -1 except root | ||
# # Space Complexity: O(?) | ||
def bfs(self): |
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.
👍 Niiice!
No description provided.