Overview
Property | Value |
---|
Best Case | O(1) |
Worst Case | O(lgn) |
Aux. Memory | O(1) |
A recursive solution looks as follows:
We can also write this iteratively:
Bibliography
- Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).