Skip to content

Conversation

@sumitrac
Copy link

@sumitrac sumitrac commented Nov 8, 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.

Nice work Sumitra, you hit the learning goals here. Well done. I found a few things on space/time complexity. Otherwise well done.

Comment on lines +16 to 18
# Time Complexity: O(log n)
# 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.

👍

Comment on lines +50 to 52
# 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.

👍 However the space complexity is O(log n) due to the recursive call stack.

Comment on lines +70 to 72
# 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 +94 to 96
# 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 +118 to 120
# 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 +142 to 144
# Time Complexity: O(n)
# Space Complexity: O(1)
def height(self):

Choose a reason for hiding this comment

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

👍 However the space complexity is O(log n) for a balanced tree.


return self.helper_bf(self.root, nodes_in_tree)

def helper_bf(self, node, nodes_in_tree):

Choose a reason for hiding this comment

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

Do you need the helper? You're not doing recursion.

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