Foundations of Algorithms Assignment 3 Chinmay Kulkarni (ck1166)
Foundations of Algorithms Assignment 3 Chinmay Kulkarni (ck1166)
Chinmay Kulkarni(ck1166)
1.a.
[ 1
3]
[6
8]
[ 7
5]
[4
2]
by Strassens Algorithm
Let,
[ A
B]
[E
F]
[ C
D]
[G
H]
[ P6+P5+P4-P2
[ P3+P4
[ -12+48-10-8
[ 72-10
[18
14]
[62
66]
P1+P2 ]
P1+P5-P3-P7]
6+8
6+48-72+84]
strassens_algo(A,B):
divide matrix A in sub-matrices A11,A12,A21,A22
divide matrix B in sub-matrices B11,B12,B21,B22
P1 A11*(B12-B22)
P2 (A11+A12) * (B22)
P3 (A21+A22) * (B11)
P4 (A22) * (B21-B11)
P5 (A11+A22) * (B11+B22)
P6 (A12-A22) * (B21+B22)
P7 (B21-B11) * (B11+B12)
C11 P5 + P4 - P2 + P6
C12 P1 + P2
C21 P3 + P4
C22 P5 + P1 - P3 - P7
Let n<2k
We can pad (2k-n) rows and columns with 0s to the original matrix so that overall order of the
matrix can be changed to some power of 2 ie n x n ,where n=2 k.
Now we can apply Strassens algorithm to the matrix. Therefore the resulting algorithm will run in
(nlg 7).
d. suppose, x = a + ib and y = c + id
n/2=k
k (n+1)/2 < k+1
2k n+1 < 2k+2
2k-1 n < 2k+1
----------------(1)
(n+1)/2 =k
k n/2 < k+1
2k n < 2k+2
-----------------(2)
b. n/2+1=(n+1)/2
suppose n/2+1=(n+1)/2=k
n/2+1=k
n/2= k 1
--------------------(1)
(n+1)/2=k
k< (n+1)/2 k+1
2k < n+1 2k+2
2k-1 < n 2k+1
-----------------------(2)
base step :
for n=1,
D(1)= lg 1+2
= 0+2
=2
It holds true
Inductive step:
Let k be any integer k >= 1, suppose it is true for 1ik, ie D(i) is true,
Now we have to show that D(k+1) is true. That is D(k+1) = lg (k+1)+2
As we know that D(k)= D(k/2) +1
For D(k+1) = D((k+1))+1
= [ lg (k+1) +1]+1
n)+1)
=lg (k+1) +2
Hence proved.
e. T(n) T (1) =
n-1
k=1 D(k)
Taking RHS,
=
n-1
k=1 D(k)
n-1
k=1T(k+1) T(k)
n-1
k=1T(k+1) -
n-1
k=1T(k)
n-1
k=1lg k +2