Home▸Algorithms & AI▸Quickselect: Expected Comparisons and Pivot Rounds on a Bar Array (2D)

Quickselect: Expected Comparisons and Pivot Rounds on a Bar Array (2D)

The same quickselect trace as the 3D scene drawn as bars: pivot, active window and discarded sides, with the exact expected comparison curve and a Monte Carlo estimate underneath.

Algorithms & AI2DModerate60 FPS📱 Mobile-adapted🟠 Blender⇄ 3D version
Quickselect: Expected Comparisons and Pivot Rounds on a Bar Array (2D) ↗ Open standalone

Pick the k-th smallest element with randomized quickselect and watch each pivot round shrink the active window of a 3D bar array. Compare the measured comparison count with the exact expectation 2[n+3+(n+1)H_n-(n+3-k)H_(n+1-k)-(k+2)H_k], see why the median costs about 3.39 n, and switch to a sorted-input first-element pivot to meet the n(n-1)/2 worst case. Blender-built bars and pivot marker, with independent numerical checks built in.

⚙ Under the hood

The same quickselect trace as the 3D scene drawn as bars: pivot, active window and discarded sides, with the exact expected comparison curve and a Monte Carlo estimate underneath.

QuickselectSelection AlgorithmExpected ComparisonsMedianRandomized Algorithms

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)