Implementation of C lower_bound
Here are the equivalent implementations of upper_bound and lower_bound. This algorithm is O(log(n)) in the worst case, unlike the accepted answer which gets to O(n) in the worst case. Note that here high index is set to n instead of n – 1. These functions can return an index which is one beyond the bounds … Read more