Fast Multiplication
Explore fast multiplication methods with recursion by implementing the Karatsuba algorithm. Understand how splitting numbers and reducing recursive calls optimizes multiplication beyond the traditional quadratic approach. This lesson guides you through the divide-and-conquer strategy and its improvements for efficient number multiplication.
We'll cover the following...
Divide-and-conquer algorithm
Two ancient algorithms for multiplying two -digit numbers in time are the grade-school lattice algorithm and the Egyptian peasant algorithm. Maybe we can get a more efficient algorithm by splitting the digit arrays in half and exploiting the following identity:
This recurrence immediately suggests the following divide-and-conquer algorithm to multiply two -digit numbers, and . Each of the four sub-products and is computed recursively, but the multiplications in the last line are not recursive because we can multiply by a power of ten by shifting the digits to the left and filling in the correct number of zeros, all in time.
Algorithm
...