Skip to content

Bogo sort.

[I wrote this on the twenty-second of April, 2007.  Sorting algorithms were so magical back then.]

“The Archetypical Perversely Awful Sorting Algorithm”

Bogo sort is a wonderful sorting algorithm. It is, in sheer awesomeness, second to none. Allow me to explain.

The algorithm for Bogo sort is described thusly: Imagine that you have a deck of cards that you desire to sort. First, throw them all into the air. Try to get a nice spread, maybe catch the wind a little. Then, pick up the cards one at a time (without prejudice to what you can see of those that land face-up). Check to see if they are in order. They aren’t!? Repeat.

Best Case: O(n). Theoretically you could get them in order on the first try.

Average Case: O(n*n!). More realistically you won’t get them in order for a very, very, very long time.

Worst Case: O(unbounded). Perhaps you won’t get them in order ever?

This means that Bogo sort will take about 1.33e62 years to finish sorting a deck of cards (minus the jokers and those silly rules cards) on average, assuming that it takes you only one second to throw the cards into the air, pick them up, check their order and then be ready to throw them again. Kind of ridiculously fast for a human, but super duper slow for a robot, so it averages out.

To put that into perspective the universe is estimated to be 1.37e10 years old. It would take you some 9.7e51 times that long to successfully sort a deck of cards using this ridiculously awesome algorithm.

DUDES. You don’t even understand how awesome this is.

(SO AWESOME.)

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

 

Better Tag Cloud