http://www.perlmonks.org?node_id=817755


in reply to Re^8: Modified Binary Search
in thread Modified Binary Search

A well implemented binary search is O(logN) worst case, but averages O(logN - 1).
That's wrong on multiple levels. First of all, your notation is sloppy. O(log N) and O(log N - 1) are equivalent classes. Any function that is in one class is also in the other.

I assume you mean that on average, a well implemented binary search only needs log N - 1 comparisons on average. But that's not true either. That's only true if you only search for elements that are present. Each unsuccessful search will take ceil(log N) or floor(log N) comparisons.