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

Rock - Delia #37

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

Rock - Delia #37

wants to merge 1 commit into from

Conversation

Parseluni
Copy link

No description provided.

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 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):

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):

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)

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):

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):

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):

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):

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):

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