Bogo sort — the algorithm that proves sometimes the worst solution is the funniest
#bogosort #sorting #computerscience
Bogo sort — the algorithm that proves sometimes the worst solution is the funniest
The entire algorithm is two steps: randomly shuffle the array, then check if it's sorted. If not, shuffle again. No comparisons, no swaps, no strategy. Just pure randomness until the universe cooperates.
The expected number of shuffles for n elements is n! (n factorial). For 10 elements that's 3,628,800 attempts. For a deck of 52 cards, it's 8 × 10^67 — more than the number of atoms in the observable universe.
There's a quantum computing joke version called "quantum bogo sort" that theoretically sorts in O(1) by destroying all universes where the array isn't sorted. Computer scientists have a dark sense of humor.
#bogosort #sorting #computerscience
Comments
Comments from the original post on Instagram
No comments yet
