You are on page 1of 15

Chapter 4 Divide and Conquer

Masroor Hussain
Professor
Faculty of Computer Science and Engineering

1
2
Recursion
• Whenever a recurrence is stated without an explicit base case, we assume that the
recurrence is algorithmic.

3
Strassen’s algorithm

for matrix multiplication

4
Standard Matrix Multiplication
Recap

5
Strassen’s Matrix Multiplication

• The standard matrix multiplication algorithm of two n × n


matrices takes O(n3) operations.
• Strassen’s algorithm is a Divide-and-Conquer algorithm that
is asymptotically faster, i.e. O(nlg 7).
• The usual multiplication of two 2 × 2 matrices takes 8
multiplications and 4 additions.
• Strassen showed how two 2 × 2 matrices can be multiplied
using only 7 multiplications and 18 additions.

6
Motivation
• For 2 × 2 matrices, there is no benefit in using the method.
• To see where this is of help, think about multiplication two
(2k) × (2k) matrices.
• For this problem, the scalar multiplications and additions
become matrix multiplications and additions.
• An addition of two matrices requires O(k2) time, a
multiplication requires O(k3).
• Hence, multiplications are much more expensive and it
makes sense to trade one multiplication operation for 18
additions.

7
Recursive Matrix Multiplication

• Suppose that we partition each of A, B, and C into four n/2 x n/2


matrices

• Here

8
Recursive Matrix
Multiplication..

T(n)=?

9
Time complexities
• Recursive Matrix Multiplication

• Strassen’s Matrix Multiplication

10
Strassen’s Algorithm

11
OR …

12
Show?

13
Complexity
• T(n) = 7 T(n/2) +cn2
• The solution works out to be: T(n) = (nlg 7) = O(n2.81) by
applying master’s method.
• Currently, the best known algorithm was given by
Coppersmith and Winograd and has time complexity
O(n2.376).

14
?

15

You might also like