|
|
|
|
|
by Jensson
1326 days ago
|
|
Binary search can be done on anything, not just arrays. Often you apply it to an algorithm and there isn't a collection at all, you just know the right answer is between some numbers so binary search lets you find it in logarithmic number of tries. If computing the number is costly then binary search is necessary to compute the result at all in those cases. |
|
However, the linked-to binary search starts from 0:
and the promoted fix is: The aforementioned Wikipedia binary sort also takes a length, rather than start/end: