News for hackers. Stuff that matters.
Re:Ask HN: What's your favorite elegant/beautiful algorithm? by unsupported on Wednesday October 17, 2018 @04:13AM (#18237129)
Reservoir sampling or Algorithm R. It allows you to randomly choose a sample of k items (with equal probability) from an "infinite" stream of items. At first it sounds impossible, but the solution and proof are extremely simple and elegant.

There are no comments on this comment yet.