The sound of sorting – 15 algorithms in 6 minutes

Sorting algorithms are an essential chapter in undergraduate computer science education. Due to their easy to explain nature and fairly straight-forward analysis, this set of algorithms offers a convenient introduction to the methods and techniques of theoretical computer science and algorithm analysis.

Timo Bingmann created a demo program for sorting algorithms. It’s called “The Sound of Sorting”visualises the algorithms internals and their operations, and generates sound effects from the values being compared. See below. The output is pretty awesome.

He’s putting the rithm in algorithm! Terrible joke. Love it. 

Here’s a breakdown of the “sound of sorting,” for want of a better term:

  • Selection sort 0:00
  • Insertion sort 0:10
  • Quick sort 0:39
  • Merge sort 1:06
  • Heap sort 1:29
  • Radix sort (LSD) 1:55
  • Radix sort (MSD) 2:11
  • std::sort (intro sort) 2:33
  • std::stable_sort (adaptive merge sort) 3:05
  • Shell sort 3:37
  • Bubble sort 4:00
  • Cocktail shaker sort 4:18
  • Gnome sort 4:34
  • Bitonic sort 4:53
  • Bogo sort (first 30 seconds) 5:17

Ending with “Bogo sort” is a wonderful little joke, somewhat like the Beatles sticking“Revolution 9” at the end of side 4. A bogo sort is a phenomenally inefficient sort that amounts to not sorting at all.

As Wikipedia explains,

In computer science, bogosort (also stupid sort or slowsort) is a particularly ineffective sorting algorithm based on the generate and test paradigm. It is not useful for sorting…. If bogosort were used to sort a deck of cards, it would consist of checking if the deck were in order, and if it were not, throwing the deck into the air, picking the cards up at random, and repeating the process until the deck is sorted. Its name comes from the word bogus.

Here’s his own page if you want to download the sources: http://panthema.net/2013/sound-of-sorting/