Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work Ana, you hit the main learning goals here. Well done. I did have some comments on space/time complexity. Please take a look and let me know what questions you have.
| # Time Complexity: o(log(n)) | ||
| # Space Complexity: o(1) | ||
| def add(key, value = nil) |
There was a problem hiding this comment.
👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.
| # Time Complexity: o(n) | ||
| # Space Complexity: o(n) | ||
| def find(key) |
There was a problem hiding this comment.
👍 the time complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced. The space complexity is the same due to recursion.
| # Time Complexity: o(n) | ||
| # Space Complexity: o(n) | ||
| def inorder |
| # Time Complexity: o(n) | ||
| # Space Complexity: o(n) | ||
| def preorder |
| # Time Complexity: o(n) | ||
| # Space Complexity: o(n) | ||
| def postorder |
| # Time Complexity: o(n) | ||
| # Space Complexity: o(n) | ||
| def height |
There was a problem hiding this comment.
👍 The space complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced due to the recursion. You have the time complexity right.
No description provided.