Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Melissa, you hit the learning goals here. Well done! Take a look at my comments and let me know what questions you have, primarily on space/time complexity.
| # Time Complexity: O(log n) if tree is balanced | ||
| # Space Complexity: O(n) ? | ||
| def add(self, key, value = None): |
There was a problem hiding this comment.
👍 The time complexity is O(log n) for a balanced tree and O(n) for an unbalanced one. Space complexity is the same due to the call stack.
| # Time Complexity: O(log n) if tree is balanced | ||
| # Space Complexity: O(n) ? | ||
| def find(self, key): |
There was a problem hiding this comment.
👍 The time complexity is O(log n) for a balanced tree and O(n) for an unbalanced one. Space complexity is O(1) because you have an iterative solution!
| # Time Complexity: O(n) | ||
| # Space Complexity: Dependent on the size/height of tree, O(h) | ||
| def inorder(self): |
There was a problem hiding this comment.
👍 Because you're building a list of all the nodes, the space complexity is O(n)
| # Time Complexity: O(n) | ||
| # Space Complexity: Dependent on the size/height of tree, O(h) | ||
| def preorder(self): |
There was a problem hiding this comment.
👍 Because you're building a list of all the nodes, the space complexity is O(n)
| # Time Complexity: O(n) | ||
| # Space Complexity: Dependent on the size/height of tree, O(h) | ||
| def postorder(self): |
There was a problem hiding this comment.
👍 Because you're building a list of all the nodes, the space complexity is O(n)
| # Time Complexity: O(n) | ||
| # Space Complexity: Dependent on the size/height of tree, O(h) | ||
| def height(self): |
No description provided.