However, the linked-to binary search starts from 0:
1: public static int binarySearch(int[] a, int key) {
2: int low = 0;
3: int high = a.length - 1;
and the promoted fix is: 6: int mid = low + ((high - low) / 2);
The aforementioned Wikipedia binary sort also takes a length, rather than start/end: function binary_search(A, n, T) is
L := 0
R := n − 1The lower_bound you pointed to takes start/end iterators defining the partially-ordered range to examine.
The linked-to essay and the Wikipedia take array + size.
These are different APIs.
The latter - which is what this thread is about, IMO - is easier to implement because the sizes are always non-negative.