[Verse 1] When numbers grow massive, traditional methods crawl Polynomial time complexity hitting a wall But Karatsuba cracked the code back in sixty-two Split those digits, conquer fast, let me show you what to do Take your multiplicands, divide them clean in half High bits and low bits on separate math paths Instead of four operations, we only need three Recursion cuts the workload exponentially [Chorus] Split and conquer, that's the way we roll Three mults instead of four, that's how we take control n to the log base two of three, complexity divine Karatsuba multiplication, optimizing every line Divide the problem, solve the parts Combine results with algorithmic arts [Verse 2] Picture x and y as giants we must tame Break each into pieces, play the splitting game x equals a times base to the m plus b below y equals c times base to the m plus d in tow Traditional approach would multiply all four But Karatsuba's genius opens up a different door Calculate ac, bd, then the magic middle term Parentheses around a plus b times c plus d confirm [Chorus] Split and conquer, that's the way we roll Three mults instead of four, that's how we take control n to the log base two of three, complexity divine Karatsuba multiplication, optimizing every line Divide the problem, solve the parts Combine results with algorithmic arts [Bridge] Subtract what you computed, ac and bd away From that middle product, the crossterm will display Left shift the high result, right shift stays in place Add them all together, watch efficiency embrace Base case kicks in when digits get too small Switch to grade school methods, answer nature's call [Verse 3] Big integer libraries use this every day RSA encryption moving data the Karatsuba way Recursive implementation, stack frames multiply Or iterative approach when memory runs dry Time complexity improves from n squared down To n raised to one point five eight, wearing the crown Space trade-offs matter when the call stack grows deep But asymptotic gains are promises we keep [Outro] From Moscow State University to silicon today Karatsuba's legacy shows us the optimal way When brute force fails you, think divide and conquer through Mathematical elegance in algorithms true
← Strassen's matrix multiplication | Closest pair of points →