What is the space complexity of recursive tree traversals?
Practice Questions
1 question
Q1
What is the space complexity of recursive tree traversals?
O(n)
O(log n)
O(1)
O(n log n)
The space complexity of recursive tree traversals is O(h), where h is the height of the tree. In the worst case of a skewed tree, this can be O(n), but for balanced trees, it is O(log n).
Questions & Step-by-step Solutions
1 item
Q
Q: What is the space complexity of recursive tree traversals?
Solution: The space complexity of recursive tree traversals is O(h), where h is the height of the tree. In the worst case of a skewed tree, this can be O(n), but for balanced trees, it is O(log n).