Skip to content

Conversation

@kashenafi
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 Kal, thanks for getting this in. Well done.

Comment on lines +19 to +21
# Time Complexity: O(log n) if balanced, otherwise O(n) where n is number of nodes
# Space Complexity: O(n), n is height
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.

👍 Yeah recursion! You threw me with the O(n) space complexity until I saw the note on height.

Comment on lines +43 to 45
# Time Complexity: O(log n) if balanced
# 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.

👍 I assume space complexity is related to the height.

Comment on lines +60 to 62
# Time Complexity: O(n), n is number of nodes
# 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 +74 to 76
# 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 +87 to 89
# 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.

👍

# Space Complexity:
def height
raise NotImplementedError
def height(current = @root)

Choose a reason for hiding this comment

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

👍 Time/space complexity?

Comment on lines 125 to 127
# Time Complexity:
# Space Complexity:
def bfs

Choose a reason for hiding this comment

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

Yeah BFS!

Time/space complexity

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