|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
Want
to multiply two large
|
|
|
|
numbers,
each of size n
|
|
|
| |
Using
traditional algorithm,
|
|
|
|
T(n)
= O(n2)
|
|
|
| |
Idea:
break each number
|
|
|
into
two pieces
|
|
|
|
A2(n/2)
+ B and
|
|
|
|
C2(n/2)
+ D
|
|
|
| |
The
result of multiplication is
|
|
|
AC2n
+ (AD+BC)2(n/2) + BD
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
Now
we accomplish our
|
|
|
|
multiply
of size n by doing 4
|
|
|
multiplies
of size (n/2)
|
|
|
| |
Recurrence
|
|
|
|
T(n) =
4T(n/2) + n
|
|
|
|
and
T(1) = 1
|
|
|
| |
This
can be solved to show
|
|
|
T(n)
= O(n2)
|
|
|
|
Wait a
minute! This isnt any
|
|
|
|
better
than the method we
|
|
|
|
learned
in 3rd grade
|
|
|
|