Skip to content

Conversation

YasminM11
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 -20 to 21
# Time Complexity:
# Space Complexity:
# Space Complexity: o(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.

The space/time complexity is O(log n) if the tree is balanced and O(n) if it's not.

Comment on lines +61 to 62
# 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 space/time complexity is O(log n) if the tree is balanced and O(n) if it's not.

Comment on lines +80 to 82
# 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 +97 to 99
# 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 +115 to 117
# 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 +133 to 135
# 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.

Because your recursive stack depends on the height of the tree the space complexity is O(log n) for balanced trees and O(n) for unbalanced trees.

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