Skip to content

Conversation

@dnsrocha
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 Denise, you hit the learning goals here. I had some notes on space/time complexity. Otherwise awesome work.

Comment on lines +19 to +22
# Time Complexity: log(n)
# Space Complexity: log(n)

def add_helper(key, value, current)

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 right if the tree is balanced and O(n) if not.

Comment on lines +52 to 54
# Time Complexity: O(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.

👍 The time complexity is right if the tree is balanced and O(n) if not. The space complexity (due to the call stack) is the same as the time complexity.

Comment on lines +73 to +76
# Time Complexity: O(n)
# Space Complexity: O(n)

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

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 +90
# Time Complexity: O(n)
# Space Complexity: O(n)

def preorder_helper(current, values)

Choose a reason for hiding this comment

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

👍

Comment on lines +107 to +110
# Time Complexity: O(n)
# Space Complexity: O(n)

def postorder_helper(current, values)

Choose a reason for hiding this comment

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

👍

Comment on lines +126 to +128
# Time Complexity: o(n)
# Space Complexity: O(h), where h = height
def height(current = @root)

Choose a reason for hiding this comment

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

👍 Nice work on the space/time 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