Skip to content

Conversation

@morganschuler
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, you hit the basic learning goals, with some issues on space/time complexity. Check out my comments and let me know if you have any questions.

Comment on lines +19 to 21
# Time Complexity: O(log (n))
# Space Complexity: O(log (n))
def add(key, value)

Choose a reason for hiding this comment

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

👍

Comment on lines +38 to 40
# 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.

If the tree is balanced this is O(log n) for both time & space and O(n) if it's not.

Comment on lines +55 to 57
# 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 +72 to 74
# 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 +89 to 91
# 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 +106 to 108
# 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.

You're visiting each node so the time complexity is right, but the space complexity (for a balanced tree) is O(log n ) because your call stack will never get greater than the height of the tree.

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