Interpolation Search
An algorithm for searching in a sorted array that estimates the position of the target element based on the values at the current bounds, similar to how a human searches a dictionary.
Parameters
Visualization
Step: 0Algorithm Insight
Predicts the location of the target mathematically:
-
1.
Calculate the probe position (
pos). -
2.
If
arr[pos] == target, search is complete! -
3.
If target is larger,
low = pos + 1. If smaller,high = pos - 1.
Efficiency
Overview
Binary search always probes the midpoint. Interpolation search estimates a probe from the target’s value relative to the current endpoints. This can reduce work on sorted data with roughly uniform spacing, but performs poorly on clustered values.