← Back to Gallery
SORTED!

Bogosort

Array size limited to 10. Expected shuffles for 6 elements: 720
Shuffles:0
Checks:0
Expected (n!):720
Check Progress:--
Status:Ready

Bogosort (Stupid Sort)

The anti-algorithm: randomly shuffle the array, then check if it happens to be sorted. If not, shuffle again. And again. And again...

Worst:   O(∞) unbounded!
Average: O(n × n!)
Best:    O(n) (already sorted)
Space:   O(1)

For 6 elements, expect ~720 shuffles on average. Don't try this on real data.