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 - Hannah L. #43

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

Rock - Hannah L. #43

wants to merge 1 commit into from

Conversation

hlumapas
Copy link

@hlumapas hlumapas commented Dec 4, 2021

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.

Overall nice work Hannah, one typo preventing the tests from passing, but otherwise nice work.

def add_helper(self, current_node, key, value):
if current_node == None:
return TreeNode(key, value)
elif key <= current_node:

Choose a reason for hiding this comment

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

This is why some tests are failing.

Suggested change
elif key <= current_node:
elif key <= current_node.key:

Comment on lines +33 to 35
# Time Complexity: O(log n)
# 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 +59 to 61
# 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 +84 to 86
# Time Complexity: O(n)
# Space Complexity: O(n)
def preorder(self):

Choose a reason for hiding this comment

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

👍

Comment on lines +102 to 104
# 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 +117 to +124
left_height = 1 + self.max_height_helper(root.left, height)
right_height = 1 + self.max_height_helper(root.right, height)

# compare to find max
if left_height < right_height:
return right_height
else:
return left_height

Choose a reason for hiding this comment

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

You can also do this with the max function

Suggested change
left_height = 1 + self.max_height_helper(root.left, height)
right_height = 1 + self.max_height_helper(root.right, height)
# compare to find max
if left_height < right_height:
return right_height
else:
return left_height
left_height = 1 + self.max_height_helper(root.left, height)
right_height = 1 + self.max_height_helper(root.right, height)
return max(right_height, left_height)

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