Fisher-Yates Shuffle vs Reservoir Sampling
Updated: Aug 2, 2025
Problem
The difference between the two is that they do different things:
| Algorithm | Input | Output | Time | Space |
|---|---|---|---|---|
| FISHER-YATES SHUFFLE | n elements | A list containing all n elements in a random order | O(n) | O(n) |
| RESERVOIR SAMPLING | n elements and integer k | A set containing k of the n elements, selected randomly | O(n) | O(k) |
Fisher Yates| n elements | a list containint all n elements in random order| O(n) | O(n)