interpolation search (sometimes referred to as extrapolation search) is an algorithm for searching for a given key value in an indexed array that has been ordered by the values of the key. it parallels how humans search through a telephone book for a particular name, the key value by which the book's entries are ordered. in each search step it calculates where in the remaining search space the sought item might be, based on the key values at the bounds of the search space and the value of the sought key, usually via a linear interpolation. the key value actually found at this estimated position is then compared to the key value being sought. if it is not equal, then depending on the comparison, the remaining search space is reduced to the part before or after the estimated position. this method will only work if calculations on the size of differences between key values are sensible. by comparison, the binary search always chooses the middle of the remaining search space, discarding one half or the other, again depending on the comparison between the key value found at the estimated position and the key value sought. the remaining search space is reduced to the part before or after the estimated position. the linear search uses equality only as it compares elements one-by-one from the start, ignoring any sorting. on average the interpolation search makes about log(log(n)) comparisons (if the elements are uniformly distributed), where n is the number of elements to be searched. in the worst case (for instance where the numerical values of the keys increase exponentially) it can make up to o(n) comparisons. in interpolation-sequential search, interpolation is used to find an item near the one being searched for, then linear search is used to find the exact item. ==performance== using big-o notation, the performance of the interpolation algorithm on a data set of size n is o(n); however under the assumption of a uniform distribution of the data on the linear scale used for interpolation, the performance can be shown to be o(log log n).weiss, mark allen (2006). data structures and problem solving using java, pearson addison wesleyarmenakis, a. c., garey, l. e., gupta, r. d., an adaptation of a root finding method to searching ordered disk files, bit numerical mathematics, volume 25, number 4 / december, 1985.sedgewick, robert (1990), algorithms in c, addison-wesley however, dynamic interpolation search is possible in o(log log n) time using a novel data structure.andersson, arne, and christer mattsson. âdynamic interpolation search in o(log log n) timeâ. in automata, languages and programming, edited by andrzej lingas, rolf karlsson, and svante carlsson, 700:15â27. lecture notes in computer science. springer berlin / heidelberg, 1993. http://dx.doi.org/1
Search_algorithms