Strassen's Algorithm For MATRIX MULTIPLICATION
Strassen's Algorithm For MATRIX MULTIPLICATION
1 2 3
Divide Conquer Combine
DIVIDE-AND-CONQUER APPROACH:
To find the maximum and minimum element from a given
array is an application for divide and conquer. In this Some standard algorithms that
problem, we will find the maximum and minimum
elements in a given array. In this problem, we are using a
follow Divide and Conquer
divide and conquer approach(DAC) which has three steps algorithm are:-
divide, conquer and combine.
Quicksort
Merge sort
Strassen’s Algorithm
DIVIDE AND RECURRENCE
CONQUER RELATION FOR
ALGORITHM : DAC ALGORITHM :
DAC(a, I, j)
{
If(small(a, I, j))
return(Solution(a, I, j)) T(n) = O(1) if n is small;
else f1(n) + 2T(n/2) + f2(n)
mid = divide(a, I, j)
b= DAC(a, I, mid)
c = DAC(a, mid+1, j)
d= combine(b, c)// f2(n)
return(d)
}
MERGE SORT STEPS
1) Divide: Divide the list or array
recursively into two halves until it
can no more be divided.
3) Merge: The sorted subarrays are MERGE SORT IS A SORTING ALGORITHM THAT FOLLOWS
merged back together in sorted THE DIVIDE-AND-CONQUER APPROACH. IT WORKS BY
order. The process continues until RECURSIVELY DIVIDING THE INPUT ARRAY INTO
all elements from both subarrays SMALLER SUBARRAYS AND SORTING THOSE
have been merged. SUBARRAYS THEN MERGING THEM BACK TOGETHER TO
OBTAIN THE SORTED ARRAY.
Merge Sort
Merge sort Algorithm:
MERGE(A, p, q ,r)
1 n1= q -p + 1
2 n2=r- q
3 let L(1..n1 +1) and R(1..n2 +1) be new
arrays
4 for i=1 to n1
5 L(i)=A(p+i-1)
6 for j =1 to n2
7 R(j)=A(q+j)
8 L(n1 +1) = ♾️
9 R(n2+1) = ♾️
10 i=1
11 j=1
12 for k =p to r
13 if L(i)<=R(j)
14 A(k)=L(i)
15 i=i+1
16 else A(k)=R(j)
17 j=j+1
COMPLEXITY
ANALYSIS OF Average Case Worst Case
Best Case
MERGE SORT:
Time Complexity;
O(n log n)
O(n log n)
O(n log n)
When the array is
When the array is
already sorted or When the array is
sorted in reverse
nearly sorted. randomly ordered.
order.
EXAMPLE:
38 27 43 10
Merge [38] and [27] to get
DIVIDE [38] is already sorted. [27, 38].
[27] is already sorted. Merge [43] and [10] to get
[10,43].
38 27 43 10 [43] is already sorted.
Merge [27, 38] and [10,43] .
[10] is already sorted.
DIVIDE
DIVIDE
10 27 38 43
4.2 STRASSEN’S ALGORITHM FOR MATRIX
MULTIPLICATION
WHAT IS STRASSEN’S
ALGORITHM?
Strassen’s method I K
reduces the time
Z= J L
complexity from O(n^3) to
O(n^log7).
It can be performed only A C
on square matrices where X= B D
n is a power of 2.
Divide matrices X, Y, and Z
into four (n/2) × (n/2) E G
Y=
submatrices as follows: F H
QUESTION- 4.2-1
USE STRASSEN’S ALGORITHM TO COMPUTE THE MATRIX PRODUCT:
M1 = (A + C) × (E + F)
M1 = 6
M2 = (B + D) × (G + H)
M2 = 8
M3 = (A - D) × (E + H)
M3 = 72
M4 = A × (F - H)
M4 = −10
M5 = (C + D) × E
M5 = 48 So, we get the final result:
M6 = (A + B) × H
M6 = −12
M7 = D × (G - E)
M7 = −84
Then:
I = C11 = 48 − 10 − 8 − 12 = 18
I = C11 = M2 + M3 - M6 - M7
J = C12 = 6 + 8 = 14
J = C12 = M4 + M6
K = C21 = 72 − 10 = 62
K = C21 = M5 + M7
L = C22 = 48 + 6 − 72 + 84 = 66
L = C22 = M1 - M3 - M4 - M5
Thank you
very much!
Group 7