Open
Conversation
CheezItMan
reviewed
Sep 2, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
Well done Chelsea, you hit all the requirements. Nice work!
Comment on lines
+20
to
22
| # Time Complexity: log n because it is binary to find where to add the node | ||
| # Space Complexity: worst case O(n) because we hit every node better average case like in a balanced tree it would be O(log n) | ||
| def add(key, value) |
Comment on lines
+53
to
55
| # Time Complexity: log n due to the binary search | ||
| # Space Complexity: worst case O(n) because we hit every node better average case like in a balanced tree it would be O(log n) | ||
| def find(key) |
Comment on lines
+78
to
80
| # Time Complexity: O(n) because it has to go through every node. | ||
| # Space Complexity: worst case O(n) because we hit every node better average case like in a balanced tree it would be O(log n) | ||
| def inorder |
Comment on lines
+102
to
104
| # Time Complexity: O(n) because it has to go through every node. | ||
| # Space Complexity: worst case O(n) because we hit every node better average case like in a balanced tree it would be O(log n) | ||
| def preorder |
There was a problem hiding this comment.
The space complexity for these traversals is O(n) because we're building an array.
With recursion it would be O(n + n) = O(2n) = O(n) or average case O(n + log n) = O(n)
Comment on lines
+126
to
128
| # Time Complexity: O(n) because it has to go through every node. | ||
| # Space Complexity: worst case O(n) because we hit every node, better average case like in a balanced tree it would be O(log n) | ||
| def postorder |
There was a problem hiding this comment.
👍 With the earlier note on the traversals.
Comment on lines
+151
to
153
| # Time Complexity: O(n) because we hit eery node | ||
| # Space Complexity: worst case O(n) because we hit every node better average case like in a balanced tree it would be O(log n) | ||
| def height |
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.
No description provided.