Skip to content

Conversation

@KayKay-git
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 Kalki, you hit the learning goals here. Well done. I had a few comments on space/time complexity, otherwise outstanding work.

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

👍 Good use of default parameters. The space/time complexities are O(n) if the tree is unbalanced and O(log n) if the tree is balanced.

Comment on lines +43 to 45
# Time Complexity: O(log n)
# Space Complexity: O(l)
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 complexities are O(n) if the tree is unbalanced and O(log n) if the tree is balanced. I'm uncertain what O(l) is?

Comment on lines +63 to 65
# Time Complexity: O(n) going through each node
# Space Complexity: O(n) creating an array
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 +81 to 83
# 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 +100 to 102
# 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 +119 to 121
# 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(n) if the tree is unbalanced and O(log n) if the tree is balanced.

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