Quickselect: Expected Comparisons of Randomized Selection and the Median of an Array
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.
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.
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.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install