6 ms·
This is called bisection search (search for the largest/smallest value satisfying a given predicate). It also reminds me a little bit of exponential search (up
by truly 5y ago
This is called bisection search (search for the largest/smallest value satisfying a given predicate).
It also reminds me a little bit of exponential search (upper bound unknown), although obviously the upper bound is known in your implementation.
Bisection: https://en.wikipedia.org/wiki/Bisection_method https://en.wikipedia.org/wiki/Bisection_method
Exponential search: https://en.wikipedia.org/wiki/Exponential_search https://en.wikipedia.org/wiki/Exponential_search
A practical application of bisection search is in git bisect (https://git-scm.com/docs/git-bisect https://git-scm.com/docs/git-bisect) to find the first revision that introduced a bug.