Why it matters
Random selection powers surveys, ML train/val splits, and load testing. Correctness matters.
Advertisement
The architecture
Reservoir for streams.
Partial Fisher-Yates for arrays with k< Sort-by-random-key alternative.
Advertisement
How it works end to end
Reservoir for streams.
Partial Fisher-Yates O(k).
Sort-by-key O(n log n).