Interpolation Search

Interpolation Search

Binary search has been improved using interpolation search. This search strategy is based on the necessary value's probing position. The data collected should be sorted and evenly dispersed for this technique to perform effectively.

In terms of temporal complexity, binary search offers a significant advantage over linear search. The worst-case complexity of the linear search is O(n), whereas binary search is O(n) (log n).

In some circumstances, the target data location is known ahead of time. For instance, in the case of a telephone directory, say we want to look up Morphius' phone number. Because we may directly jump to memory space where the names beginning with 'M' are stored, linear and even binary search will appear slow.

Positioning in Binary Search

If the necessary data is not found in a binary search, the rest of the list is separated into two parts: lower and higher. In either of them, the search is carried out.

Interpolation Search Position ProbingInterpolation Search Position Probing

By computing the probe position, interpolation search locates a specific object. The probe position is initially the position of the collection's middle item.

If a match is found, the item's index is returned. We use the following formula to divide the list into two parts: mid = Lo + ((Hi - Lo) / (A[Hi] - A[Lo]) * (X - A[Lo])

where A denotes a list

Lo denotes the list's lowest index.

Hi = The list's highest index.

A[n] = Value stored in the list at index n.

If the center object is larger than the object, the probe area in the same part below the center of the center object is recalculated. If not, the item is viewed in the lower left-hand column of the main item. This process is repeated in a small list until the size of the subarray is reduced to zero.

In favorable settings, the interpolation search method has a runtime complexity of O(log (log n)), whereas BST has a runtime complexity of (log n).


We are giving the procedures to seek the 'target' data value index using position probing because it improvises the existing BST technique.

    Step 1: Begin looking for information in the middle of the list.

    Step 2: If there is a match, return the item's index and exit.

    Step 3: Probe the position if it isn't a match.

    Step 4: Using a probing formula, divide the list and locate the new midle.

    Step 5: If the data is larger than the centre, look for it in a higher sub-list.

    Step 6: If the data is less than the middle, look in the lowest sub-list.

    Step 7: Continue until you've found a match.


    An Array List N Size of A X Target Value A Array List N Size of A Array List N Size of A Array List N Size of A Array List N Size of A Array

    Search Interpolation Procedure ()

    Set Low to 0; Set Mid to -1; Set High to N-1.

    X, on the other hand, does not match.

    if Lo is the same as Hi OR A[Lo] is the same as A[Hi]EXIT: If the target is not found, the game is over.

    Mid = ((Hi - Lo) / (A[Hi] - A[Lo]) * (X - A[Lo])

    if A[Mid] = X EXIT: Success, Target located at Mid, otherwise if A[Mid] X EXIT:

    If A[Mid] > X, set Lo to Mid+1.

    Set Hi to Mid-1 at the conclusion if End While is true.