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- Briyana Haywood #38

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

Conversation

brijhaywood
Copy link

No description provided.

@brijhaywood brijhaywood changed the title Required tests passed Rock- Briyana Haywood Nov 21, 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.

Nice work Briyana, thanks for getting this in. Well done. I only left a few comments as your code looks pretty good.

# Time Complexity:
# Space Complexity:

def add_helper(self, current_node, key, value):

Choose a reason for hiding this comment

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

Nice recursive helper!

Comment on lines +28 to 30
# Time Complexity: O(log n) - balanced
# Space Complexity: O(log n)
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 to note the balanced requirement

self.add_helper(self.root, key, value)


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.

Another good recursive helper

Comment on lines +48 to 50
# Time Complexity: O(n)
# Space Complexity: O(n)
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 +31 to +34
if self.root == None:
self.root = TreeNode(key, value)
else:
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.

Could be rewritten as:

Suggested change
if self.root == None:
self.root = TreeNode(key, value)
else:
self.add_helper(self.root, key, value)
self.root = self.add_helper(self.root, key, value)

Comment on lines +65 to 67
# 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 +83 to 85
# 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.

👍

return traversal_list


def height_helper(self, current):

Choose a reason for hiding this comment

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

nice!

Comment on lines +119 to +121
# 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 the height of the tree (which worst case is n)

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