4 ms·
The larger the list it gets exponentially less likely that this occurs if the shuffling occurs at every iteration. We have 2/(n!) probability that the shuffle
by PartiallyTyped 4y ago
The larger the list it gets exponentially less likely that this occurs if the shuffling occurs at every iteration.
We have 2/(n!) probability that the shuffle sorts the list either way. The probability that it happens on the second level is 2/((n-1)!).
So the probability that it happens twice is 4/(1^2 * 2^2 … (n-1)^2 * n)
Which ends up being prod_{i=1} ^N i ^ i
It’s so astronomically unlikely, that it just never does.