Skip to content

Conversation

@agesak
Copy link

@agesak agesak commented Apr 2, 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 Kareha, you hit the learning goals here. Well done.

Comment on lines +19 to +21
# Time Complexity: O(logn)
# Space Complexity: O(logn)
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/complexities are correct if the tree is balanced and O(n) if unbalanced.

Comment on lines +42 to 44
# Time Complexity: O(logn)
# Space Complexity: O(logn)
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/complexities are correct if the tree is balanced and O(n) if unbalanced.

Comment on lines +59 to 61
# 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 +76 to 78
# 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 +93 to 95
# 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 +110 to 112
# 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.

Comment on lines +126 to 128
# Time Complexity: O(n*m)
# Space Complexity: O(n)
def bfs

Choose a reason for hiding this comment

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

Because you are using .shift the time complexity is O(n^2), otherwise well done.

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