Skip to content

Rock - Delia#37

Open
Parseluni wants to merge 1 commit intoAda-C15:masterfrom
Parseluni:master
Open

Rock - Delia#37
Parseluni wants to merge 1 commit intoAda-C15:masterfrom
Parseluni:master

Conversation

@Parseluni
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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 Delia, you hit the learning goals here. Nice work!

Comment on lines +16 to 18
# Time Complexity: O(log n) *if balanced
# Space Complexity: O(1)
def add(self, key, value = None):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Good note about being balanced.

nice iterative solution

else:
parent.right = TreeNode(key, value)

def add_helper(self, curr_node, key, value):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +53 to +57
if self.root == None:
self.root = TreeNode(key, value)
else:
# use helper method to add parameter
self.add_helper(self.root, key, value)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can be rewritten

Suggested change
if self.root == None:
self.root = TreeNode(key, value)
else:
# use helper method to add parameter
self.add_helper(self.root, key, value)
self.root = self.add_helper(self.root, key, value)

Comment on lines +60 to 62
# Time Complexity: O(log n) *if balanced
# Space Complexity: O(1)
def find(self, key):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +119 to 121
# Time Complexity: O(n)
# Space Complexity: O(n)
def inorder(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +136 to 138
# Time Complexity: O(n)
# Space Complexity: O(n)
def postorder(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment on lines +152 to 154
# Time Complexity: O(n)
# Space Complexity: O(n)
def height(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 The space complexity is O(h) where h is the height of the tree, but you're right if it's unbalanced h could be the number of nodes.

Comment on lines +161 to 163
# # Time Complexity: O(n)
# # Space Complexity: O(n)
def bfs(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Nice! You got the bonus.

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