arrayscomplexitysearching
Use a half-open range for binary search
Anonymous
For a sorted array with random access, find the first index whose value is at least target with a half-open range [lo, hi). Choose mid between the bounds. If arr[mid] < target, set lo to mid + 1; otherwise set hi to mid. When the bounds meet, lo is the answer, including n if every value is smaller. This takes O(log n) time.
0