Skip to content

Conversation

@aracelim1234
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.

Nice work Araceli. You hit the learning goals here. Well done.

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

👍

Comment on lines +41 to 43
# Time Complexity: O(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.

👍 Time complexity is O(n) if the tree is unbalanced and O(log n) if it is balanced.

Comment on lines +60 to 62
# Time Complexity: O(n)
# Space Complexity: O(1)
def inorder(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(n) because you're building a list of all the nodes.

Comment on lines +87 to 89
# Time Complexity: O(n)
# Space Complexity: O(1)
def preorder(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(n) because you're building a list of all the nodes.

Comment on lines +114 to 116
# Time Complexity: O(n)
# Space Complexity: O(1)
def postorder(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(n) because you're building a list of all the nodes.

Comment on lines +139 to 141
# 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.

👍 Because of the recursion the space complexity is O(h) where h is the height of the tree (which will be log n if the tree is balanced and it can approach n if the tree is very unbalanced).

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