Edit: question simplified to remove confusion
Assuming a sorted list of items with indexes from 1 to N
, and given only an index number i
and the maximum index N
, is there a simple function which will return the two possible indexes that would be reached next in a binary search of the list?
Example:
i = 6
N = 8
LeftSearchIndex(i, N) = 5
RightSearchIndex(i, N) = 7