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

Margaret #22

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

Margaret #22

wants to merge 2 commits into from

Conversation

msfinnan
Copy link

@msfinnan msfinnan commented Sep 9, 2019

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, you you can skip tests on the extra breadth-first-search if it's not done. You did hit the learning goals. Take a look at my comments. I think you have some issues with space complexity. If you have questions let me know via Slack.

# Time Complexity:
# Space Complexity:
# Time Complexity: O(log n) if it is balanced, O(n) if it is not
# Space Complexity: Constant

Choose a reason for hiding this comment

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

Actually since add_helper is recursive the space complexity will be O(log n) if the tree is balanced and O(n) if it's not due to the function call stack.

def height
raise NotImplementedError
# Time Complexity:O(n)
# Space Complexity:O(n)

Choose a reason for hiding this comment

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

Space complexity would be O(n) if the tree is widely unbalanced, but O(log n) if it is balanced.

# Time Complexity:
# Space Complexity:
# Time Complexity: O(n)
# Space Complexity:O(log n)

Choose a reason for hiding this comment

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

Since you are building an array in this example, it would be O(n)

Same for all the traversals

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