This Is What Popular Sorting Algorithms Sound Like

The universe of data visualisation is infinite. Just when you think you have the definitive way of representing a complex concept, someone cracks out a better (or just plain cooler) approach. Take sorting algorithms, which we’ve seen reproduced in folk-dance, now tackled by an 8-bit symphony.

A few years ago, a programmer by the name of Timo Bingmann wrote a tool called the “Sound of Sorting”. In it, you can run a number of popular sorting algorithms — quicksort, insertion, merge, etc. — and not only will it produce a visual, but an aural experience too.

The question now is, how does the program produce the soundtrack, which as Bingmann himself describes, has a “‘8-bit game tune’ feeling”?:

The generated sound effects depend on the values being compared. Only comparisons yield sound output (except for in radix/bucket sort)! The length of each comparison’s sound effect can be modified using the “Sound Sustain” slider. The frequency of the sound is calculated from the compared values.
 
The sound wave itself is triangular and modulated with an ADSR envelope … An item value is scaled (with double precision) to the frequency range 120Hz — 1212Hz, which is large but not too high to be annoying.

Bingmann created the Sound of Sorting for various reasons, but one of the major ones was providing a teaching tool for computer science students (or anyone interested in the internals of sorting). For example, the tool has the ability to slow down the sort, so you can see exactly how each stage functions.

If you’re not keen on downloading the program itself, the video above does a good job of showing it in action.

Sound of sorting [Panthema]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


Leave a Reply