Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Earth - Denise - Tree Practice #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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
2 participants