
Divide-and-conquer algorithms1
1 Multiplication
The mathematician Gauss once noticed that although the product of two complex numbers
seems to involve four real-number multiplications, it can in fact be done with just three:
,
, and
!
, since
" #$%&('
This speeds up the computation, but only by a constant factor, which to our big-
)
way of
thinking is negligible. Can something more substantial be salvaged from Gauss’ observation?
The seemingly modest improvement in computation time becomes very significant if this
same trick is applied recursively. Let’s move away from complex numbers and see how this
helps with regular multiplication. Suppose
*
and
+
are two
,
-bit integers. As a first step
towards multiplying them, split each of them into their left and right halves, which are
,.-0/
bits long:
*
*21 *43
/6587:9*21
*43
and
+
+1+3
/6507:9+ 1
+3
.
For instance, if
*
<;$=>;8;
9
then
*1
<;$=
9
and
*3
<;8;
9
. The product is
*?+
/
5
*1+1
/
587:9
*1+3
*3+1
@
*3+3
'
We will compute
*2+
via the expression on the right-hand side. The additions take linear time,
as do the multiplications by powers of two (which are left-shifts). The significant operations
are the four
,.-0/
-bit multiplications,
*1+1
*1+3
*3+1
*3+3
; these we can handle by four re-
cursive calls. If
A
,
denotes the time taken to multiply
,
-bit numbers by this method, then
A
,
can be written as a recurrence relation,
A
,
BDC
A
,.-0/
.
)
,
'
We will soon examine general strategies for solving such equations. In the meantime, this
particular one works out to
)
,9
, which is disappointing because it is no better than the
traditional grade-school multiplication technique. So we would like to speed up our recursive
algorithm somehow, and now Gauss’ trick comes to mind. Although the expression for
*2+
seems to demand four
,.-0/
-bit multiplications, as before just three will do:
*1+1
*3+3
, and
*21
*43
+E1
+3
, since
*F1(+3
*43G+E1
H
*21
*F3
+E1
+3
&
*F1(+E1
*F3I+3
'
The improved
running time is
A
,
BKJ
A
,.-0/
.
)
,
'
1Copyright c
L
2004 S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani.
1