Solve the following recurrence relations:
1.
T(n) = T(n/3) + n for n > 1
T(1) = 1
2.
T(n) = 4T(n/2) + n^2 for n > 1
T(1) = 1
T(n)
= T(n/3) + n
= T(n/9) + n/3 + n
=T(n/27)+ n/9 + n/3 + n
= T(n/3i) +n/3i-1 + n/3i-2 + ....... + n = n
T(n) = T(1) + n (1 + 1/3 + 1/32 + ..... + 1/3i-1 )
= T(1) + n(1(1- (1/3i)/(1- 1/3)
= 1 + 2n/3 (1- (1/3i))
Now n/3i = 1
T(n) = 1+3n/2 (1- 1/n) = 1+3n/2 * (n-1)/n = 1+3/2*(n-1) = 3n/2- 3/2+1 = 3n/2 - 1/2 = (3n-1)/2
therefore T(n) = (3n-1)/2
(b)
T(n)
= 4T(n/2) + n2
= 4 * (4T(n/4) + (n/2)2 ) + n2
= 16T(n/4) + 2n2
= 4i T(n/2i)+in2
where
n/2i = 1
n = 2i
log 2n = i
T(n) = 4log 2 n * T(1) + (log 2n)n2 = 22log 2 n * 1 + (log 2n)n2 = n2 (1 + log2n) = n2 (log22 + log2n) = n2log2(2n)
T(n) = n2log2(2n)
Get Answers For Free
Most questions answered within 1 hours.