is there an algorithm that is faster than binary search, for searching in sorted values of array?
in my case, I have a sorted values (could be any type values) in an
One possibility is to treat it like finding the roots of a function. Basically, finding:
a[i] <= i <= a[i + 1]
Is equivalent to:
a[i] - i <= 0 <= a[i + 1] - i
Then you could try something like Newton's method and so on. These kinds of algorithms frequently converge faster than a binary search when they work, but I don't know of one that is guaranteed to converge for all input.
http://en.wikipedia.org/wiki/Root-finding_algorithm