Skip to content

Conversation

@anakp07
Copy link

@anakp07 anakp07 commented Apr 14, 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 Ana, you hit the main learning goals here. Well done. I did have some comments on space/time complexity. Please take a look and let me know what questions you have.

Comment on lines +32 to +34
# Time Complexity: o(log(n))
# Space Complexity: o(1)
def add(key, value = nil)

Choose a reason for hiding this comment

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

👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.

Comment on lines +56 to 58
# Time Complexity: o(n)
# Space Complexity: o(n)
def find(key)

Choose a reason for hiding this comment

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

👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.

Comment on lines +77 to 79
# Time Complexity: o(n)
# Space Complexity: o(n)
def inorder

Choose a reason for hiding this comment

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

👍

Comment on lines +93 to 95
# Time Complexity: o(n)
# Space Complexity: o(n)
def preorder

Choose a reason for hiding this comment

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

👍

Comment on lines +109 to 111
# Time Complexity: o(n)
# Space Complexity: o(n)
def postorder

Choose a reason for hiding this comment

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

👍

Comment on lines +125 to 127
# Time Complexity: o(n)
# Space Complexity: o(n)
def height

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(log n) if the tree is balanced and O(n) if it's unbalanced due to the recursion. You have the time complexity right.

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