Today, I heard of Karatsuba algorithm, a fast multiplication algorithm. I am curious that in which sense does this “fast” mean?
Normally, we consider a multiplication operation using * operator as O(1) when calculating the time complexity of a piece of code, and if it’s always true, how come we have a faster algorithm with regard to asymptotic notation? Or * should not be considered O(1) when performed on very large numbers, where Karatsuba algorithm can be useful?
And in the machine level, compilers always do some optimization on *. For example, using bit-wise operations to multiply a number by 2^n. Does Karatsuba algorithm beat * in the actual running time?
Classical multiplication is O(n2), where n is the number of digits in the number being multiplied.
When measuring normal computer code, you’re dealing with fixed-size (typically 32-bit or 64-bit) numbers, so that becomes O(1) (since the size doesn’t change)
Once you start dealing with BigIntegers, this becomes very important.