Re: Search Algorithm
On Mon, 15 Nov 2004 10:52:22 -0800 (PST)
Sergio Basurto Juarez <sbasurtoj@yahoo.com> wrote:
> To find a key k in an array v with indexes from 0 to
> n-1, begin with x0 = 0, x1 = n-1, and i = 1. Compute
> the next position with
> xi+1 = xi - (v[xi]-k) * (xi - xi-1)/(v[xi] - v[xi-1]).
> If this lies outside the range, a different method
> (e.g., midpoint of the range) must be used to get the
> next position.
Numerical Recipies has several methods. Depending on the distribution
of your data some of these methods may prove to be faster (section 9.2 and 9.3)
http://www.library.cornell.edu/nr/bookcpdf.html
Please read their license. If I remember correctly you are only
allowed to use their code if you mention where you found it.
Reply to: