Interpolation search is an extension of the binary
search. Like the binary search the goal of the Interpolation
search is to find a certain element. In analogy to the binary
search the Interpolation search requires that the
elements are sorted in ascending order.
The basic idea is similar to leafing through the telephone book
where one Does not just chose the middle element of the search
area but decides where it is most likely to be judging by the range
limits.
To that end the difference of the first element of the interval
(the smallest element) to the element to be searched is divided by
the span of the interval values in relation to the interval length.
Multiplied with the interval boundaries that then is the
interpolated position of the element to be searched.
With approximately evenly distributed values, the expected
complexity of the Interpolation Search is ca. O(log log
n)
The animation demonstrates the course of a failed
Interpolation search and shows the source code. To better
understand the procedure, the current code line is highlighted.