Back to course home
0% completed
Vote For New Content
Proper Space Complexity Analysis
Lee
Feb 16, 2024
Calling the space complexity O(h) seems insufficient. Of course it's O(h). That's not interesting.
What's interesting is the space complexity under various scenarios. For the recursive dfs solution, the best case is when the tree is balanced. In this case the space complexity is O(log n).
For this solution, the worst case is when the tree is a linked list (only single children). In this case, the space complexity is O(n).
I feel like the solutions in this course lack appropriate rigor.
2
0
Comments
Comments
On this page