Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Scissors - Aida R. #50

wants to merge 1 commit into from

Conversation

adia-9
Copy link

@adia-9 adia-9 commented Dec 29, 2021

No description provided.

@adia-9 adia-9 changed the title Add methods to Tree class, pass all tests Scissors - Aida R. Dec 31, 2021
Copy link

@CheezItMan CheezItMan left a 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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice recursive solution!

Comment on lines +34 to +36
# 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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +50 to +53
# 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):

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)

Comment on lines +71 to +74
# 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):

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)

Comment on lines +92 to +95
# 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):

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)

Comment on lines +113 to +115
# 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):

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 )

Comment on lines +131 to 133
# # Time Complexity: O(n) where n is the number of nodes -1 except root
# # Space Complexity: O(?)
def bfs(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Niiice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants