Open
Conversation
One for empty tree, one for tree_with_nodes
Add a test for the height method
CheezItMan
reviewed
Mar 18, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Overall not bad. Take a look at my comments, mostly on BigO, and let me know any questions you have. Otherwise well done.
Comment on lines
+30
to
32
| # Time Complexity: O(log n) where n is number of nodes ? | ||
| # Space Complexity: O(n) where n is number of nodes ? | ||
| def add(key, value) |
There was a problem hiding this comment.
Since you're not add n nodes to the tree the space complexity is O(1).
Comment on lines
+66
to
68
| # Time Complexity: O(log n) where n is number of nodes ? | ||
| # Space Complexity: O(1) or is this N/A? | ||
| def find(key) |
Comment on lines
+96
to
98
| # Time Complexity: O(n) where n is number of nodes | ||
| # Space Complexity: O(n) where n is number of nodes | ||
| def inorder |
Comment on lines
+111
to
113
| # Time Complexity: O(n) where n is number of nodes | ||
| # Space Complexity: O(n) where n is number of nodes | ||
| def preorder |
Comment on lines
+126
to
128
| # Time Complexity: O(n) where n is number of nodes | ||
| # Space Complexity: O(n) where n is number of nodes | ||
| def postorder |
Comment on lines
+143
to
145
| # Time Complexity: O(n) where n is number of nodes | ||
| # Space Complexity: O(1) | ||
| def height |
There was a problem hiding this comment.
Since height_helper is recursive, this is O(log n) for space complexity. Since you'll have log n recursive calls on the stack at any one time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I originally forked this project from Ada-C11/tree-practice, and when I tried to go back to forking from Ada-C12/tree-practice instead, GitHub kept redirecting me to the already forked tree-practice repo from C11. Not sure why that happened or how to fix it, but I hope this is similar enough to the correct assignment.