From reel 189: “Why does a sorting algorithm sound like THAT?”
Sorting, out loud
100 bars, each one a note: watch and hear bubble sort, quicksort, insertion sort and merge sort put them in order. For 100 bars bubble sort always makes 4,950 comparisons; quicksort averages about 648.
Pick an algorithm and press Sort · set the speed (2 to 3,000 steps a second) and the number of bars · drag across the bars to draw your own, then sort them · Sound on
Open full screenMake your own
Ask Doodle once:
“Doodle, sort 100 shuffled bars with bubble sort and then quicksort, and play a note for every comparison”
Doodle writes both sorts in Python, counts every comparison, and charts bubble sort against quicksort.
Pitch runs from 220 Hz (shortest bar) to 1,760 Hz (tallest). The tones are synthesised in your browser.