Professional Documents
Culture Documents
Conquer
Divide-and-Conquer : Algorithm Design Strategy
The most-well known algorithm design strategy:
if (small (P))
// P is small, and solution is obvious
return solution (P);
}
Divide-and-Conquer : Examples
• Binary search
for i = 1 to n do
for j = 1 to n do
Z[i,j] := 0
for k = 1 to n
do Z[i,j] := Z[i,j] + X[i,k] × Y[k,j]
For any matrix of size 2x2 matrix, the matrix multiplication is performed as
follows-
C11 C12
C11= a*e + b*g
C12= a*f + b*h
C21= c*e + d*g
C21 C22
C22= c*f + d*h
Now, there will 4 matrices of size 2x2 for matrix A and for matrix B. These
matrices are considered as A11, A12, A21, A22 for A and B11, B12, B21,
B22 for B.
8T(n/2)+ n2 if n>2
T(n)= 1 n<=2
DAA (CS-204) PDPM IIITDM, Jabalpur 11
Analysis of Strassen’s Matrix Multiplication Algo
Recurrence relation
8T(n/2)+ n2 if n>2
T(n)= 1 n<=2
Case 1: if logba > k, then T(n)=O(nlogba)
The matrix multiplication require more effort than matrix addition and
subtraction. As, Strassen’s Matrix Multiplication need 7 matrix
multiplication it will need less effort than standard matrix multiplication
approach.