("Like It Called on Me (QuickSort)" is set to the music of "Wavin' Flag", original music and lyrics by K'naan from his album Troubadour. Alternate lyrics are by Steve Wolfman, Susanne Bradley, Rachel Pottinger, Naomi Wolfman, and the CPSC 320 2016W2 TA staff.)
You can subject yourself to video of me and Susanne singing this one.
If you'd like to play this on ukulele (and maybe guitar), try the simple chord rotation C F Am G over and over. There's lots of fun strumming patterns, but just one strum per beat (i.e., strum down C on "Pivot" and then "Smaller", strum down F on "You" and "sorted", etc.) works just fine.
Pivot and smaller, You will be sorted. I'll call on quicksort, Just like it called on me. Larger than pivot, You will be sorted. I'll call on quicksort, Just like it called on me. And then I go back, and then I go back, And then I go back. Sir Antony, built it for speed, Tuned by Bentley, writing in C But poor choice of p, adversary can scale up speed, quadratically. And it's unstable, unless it is able To use index labels, uniquely. If worst case lies, or you randomize For any large size, then quicksort takes prize So we're shuffling, till n = none, and we're wondering when we'll be done. But we patiently wait, for that trivial case, It's log n away, so for now we say: Pivot and smaller, You will be sorted. I'll call on quicksort, Just like it called on me. And then I go back, and then I go back, And then I go back. Memory space, sorted in place But in the worst cases, O(n) stack frames Reorder calls, so memory use falls Shorter half first; then tail recurse! But what are they good for, sorts that run slower? QuickSort the big wars, then call an n-squared. Heapsort falls far short for cache-conscious users And Bogo or Brute Force, they take n factorial But we're shuffling, till n = none And we're wondering when we'll be done But we patiently wait, for that trivial case, It's log n away, so for now we say: Pivot and smaller, You will be sorted. I'll call on quicksort, Just like it called on me. And then I go right, and then I go right, and then I go right, and then I go.. Larger than pivot, You will be sorted. I'll call on quicksort, Just like it called on me. And then I go back, and then I go back, and then I go back. And common cases will be n log n. And you and I will be n log n. And log n bang will be n log n. Pivot and smaller, You will be sorted. I'll call on quicksort, Just like it called on me. And then I go right, and then I go right, and then I go right, and then I go.. Larger than pivot, You will be sorted I'll call on quicksort, Just like it called on me. And then I go back, and then I go back, And then I go back. Pivot and smaller, Larger than pivot. I'll call on quicksort, Just like it called on me. Just like it called on me. Just like it called on me. Call, call, just like it called on me.