BACKGROUND:
Note: The following question arose in my mind when watching this lecture (watch at 5:30 minutes if you will).
Assumption: Just for the sake of this question, let's assume that the term "basic operation" means an addition or a multiplication operation between two single-digit numbers.
Now we have to calculate the number of basic operations involved in the simple multiplication (the one we learnt in 3rd grade) of any two numbers, provided that both the numbers have the same length (i.e. the number of digits).
Let's say n
represents the length of the numbers.
Let the numbers be 1234
and 5678
. The following image shows the multiplication:
As you can see, each row (i.e. each partial product of the first number with a digit of the second number) involves 4
multiplication operations, and 4
addition operations (think of the carries). Depending on the number of carries (and thus depending on the original numbers), in the case of any two numbers, in each row, it could be at least 0
additions (no carry) and at most 4
additions (a carry from each digit-to-digit multiplication).
In other words, each row involves ≤ 2n
operations. As there are n
rows, so the basic operations in all the rows are n(2n)
, or 2n2.
QUESTION:
Now comes that one final addition (shown in black pen in the image). From the video lecture
The final addition requires a comparable number of operations. Roughly, say, another at-most 2n2 operations.
The question is
What is meant by "comparable" number of operations?
Now, there will be at-most
n-1
_
's in the partial products, which meansn-1
addition operations. Apart from those, there will be at-leastn
additions (if there isn't a carry from the addition of the left-most digits in the partial products), and at-mostn+1
additions (if there IS a carry from the addition of the left-most digits in the partial products). This makes a total of, at-most,n-1+n+1
or2n
addition operations in this step. So why are they saying 2n2?