write a rap song about the worst-case time complexity of the bubble sort algorithm in the style of biggie smalls
GPT-3.5
GPT-6 Astra
“Quadratic Pressure”
[Verse 1]
Uh—array rolled up with the numbers all reversed,
Biggest in the front, had the smallest looking cursed.
Two neighbors face off, check who belongs where,
Left too heavy? Swap ’em—slide ’em one chair.
Big dog bubbles to the end of the line,
But the rest still crooked, so we run it one more time.
First pass, n minus one comparisons to do,
Next pass, n minus two—still a long way through.
I told the little loop, “You got expensive taste,”
All that back-and-forth, all that time you waste.
One sorted spot per pass, watch the boundary shrink,
But the bill keeps climbing quicker than you think.
[Hook]
n squared, baby—that’s the worst-case grind,
Double up the input, ’bout four times the time.
Neighbors keep trading till the order looks fine,
Bubble got a rhythm, but it takes its sweet time.
[Verse 2]
Count the checks clean, let the arithmetic speak:
One through n minus one—that’s the total we seek.
n times n minus one, then divide it by two,
That’s a quadratic tab coming straight back to you.
Reverse-sorted lineup? Every pair’s out of place,
Gotta swap each inversion in this neighbor-only race.
Same triangular count for the swaps on that ride,
No shortcut when the small ones need to reach the other side.
Drop the lower-order term, let the constants disappear,
Theta of n squared—make the tight bound clear.
Big-O’s n squared too, but Theta tells it tight:
Worst-case growth locked down from the left to the right.
[Bridge]
Got a flag for “no swaps”? That can end a sorted run,
Best case linear—one pass and you’re done.
But reversed? That flag ain’t saving your night,
Still quadratic work getting everything right.
[Hook]
n squared, baby—that’s the worst-case grind,
Double up the input, ’bout four times the time.
Constant extra space, but the clock won’t recline—
Bubble got a rhythm, but it takes its sweet time.
What changed
The real gap is in the rapping, not the facts. Both land on n squared, but GPT-3.5 mostly announces it (“Is O of n squared, that’s the report”) and pads its rhymes with filler like “no need to resort” and “no need to mask.” Its line that a sorted list is “easy peasy” quietly assumes an early-exit check it never mentions. Astra turns the derivation into verses: “n minus one comparisons,” then “n times n minus one, then divide it by two,” plus the swap-flag bridge that explains why the best case is linear but the reversed case isn’t. “Double up the input, ‘bout four times the time” is a sharp way to make quadratic growth stick.
Neither really sounds like Biggie. GPT-3.5 just says it is him and signs off with “bubble sort is wack, yo,” which has a goofy charm. Astra has better flow and swagger (“You got expensive taste”), but beyond an opening “Uh,” it could be anyone’s.