Algo Assignment 3 Solution
Algo Assignment 3 Solution
Algo Assignment 3 Solution
≤ 4T(n/4)+ cn + cn
≤ 8T(n/8) + cn + cn + cn
.
.
.
≤ 2kT(n/2k) + kcn
Let,
n/2k = 1
n = 2k
lg2n = lg22k
lg2n = k
So,
T(n) = 2lg2_nT(1) + lg2n*cn
= 2lg2_n*1 + lg2n*cn
= O(nlg2n)
5. T(n) = 2T(n/3) + Θ(nlg2n), T(1)=1
= 2T(n/3) + cnlg2n
= 2(2T(n/9) + cn/3lg2n/3 ) + cnlg2n [Substitution]
= 4T(n/9) + 4cn/3lg2n/3 + cnlg2n
= 4(2T(n/27) + cn/9lg2n/9) + 4cn/3lg2n/3 + cnlg2n [Substitution]
.
.
.
= T(n/5k) + c
Let,
n/5k = 1
n = 5k
lg5n = lg55k
lg5n = k
So,
T(n) = T(1) + c
= 1 + c
= 1 + c
= 1 + c
= 1 + c
= 1 +
= Θ(lg5n*(lg2n)2)
= Θ((lg2n/lg25)*(lg2n)2) = Θ((lg2n)3)