I have an array of sorted numbers:
pts = [ 0, 4, 25, 51, 72, 100 ]
Given value T, I need to find the index of the first number in the array greater than T.
if T = 2, then the correct index is 1 for value 4
dumb solution
I can do this with a linear search, but would like to optimize.
not working solution
Binary search algorithm examples find the index of an exact number..
Is there a suggested technique to solve this sort of search problem? Thanks!