Search Algorithm Growth Curves: Linear vs Binary vs Jump vs Interpolation
Watch the real comparison-count growth curves of Linear, Binary, Jump and Interpolation search plotted live against array size, verifying O(n), O(log n), O(sqrt n) and O(log log n) directly from measured data, plus a value-scaled number-line spotlight of one live search.
This simulator measures four classic search algorithms — Linear, Binary, Jump and Interpolation search — instead of just animating one run: for a sweep of array sizes it generates fresh sorted arrays, runs every algorithm against real present-or-absent targets, tallies the actual number of comparisons, and plots the averages as growth curves on a log-scaled chart, so O(n), O(log n), O(√n) and O(log log n) show up as measured data rather than a claim. A second panel plots one array as a number line positioned by real value rather than by index, and steps a single chosen algorithm's probes live across it — which makes it visually obvious why interpolation search's straight-line guess only works when values are roughly evenly spaced, and why a genuinely adversarial "skewed" distribution (keys spaced by a constant ratio rather than a constant difference) breaks that guess and pushes its comparison count toward linear search's, while binary search — which never looks at the values, only their order — stays completely unaffected.
Measure Linear, Binary, Jump and Interpolation search directly: for a sweep of array sizes it generates real sorted arrays, runs every algorithm against present-or-absent targets, and plots the actual average comparison counts as growth curves against the theoretical O(n), O(log n), O(sqrt n) and O(log log n) bounds, plus a value-scaled number-line spotlight of one live search.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install