-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: master
Are you sure you want to change the base?
Margaret #22
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
No description provided.