Binary search

easy

Doubling the array size costs exactly one more step. A million elements need 20 comparisons; a billion need 30. Includes the overflow bug that sat in the JDK for nine years.

Best O(1)Average O(log n)Worst O(log n)Space O(1)
Loading the binary search engine…

Where to go next