Skip to content

Conversation

@easternwashingaden
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 Lak, you hit the learning goals here. Well done. Take a look at my comments and let me know what questions you have.

Comment on lines +19 to 21
# Time Complexity: O(log n)
# Space Complexity: O(1)
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 time complexity is O(log n) assuming the tree is balanced.

Comment on lines +43 to 45
# Time Complexity: O(log n)
# Space Complexity: O(1)
def find(key)

Choose a reason for hiding this comment

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

👍

Comment on lines +59 to +62
# Time Complexity: O(n)
# Space Complexity: O(n)

def inorder(current = @root, array = [])

Choose a reason for hiding this comment

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

👍

Comment on lines +73 to +75
# Time Complexity: O(n)
# Space Complexity: O(n)
def preorder(current = @root, array = [])

Choose a reason for hiding this comment

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

👍

Comment on lines +85 to +88
# Time Complexity: O(n)
# Space Complexity: O(n)

def postorder(current = @root, array = [])

Choose a reason for hiding this comment

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

👍

Comment on lines +98 to +100
# Time Complexity: O(n)
# Space Complexity: O(n)
def height(current = @root)

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) assuming the tree is balanced and O(n) if it's 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