Use iteration to find explicit formulas for the following re

Use iteration to find explicit formulas for the following recurrences. For each problem, show your work and draw a recursion tree. Assume T(1) = 1

1. T(n)=3T(n 2 ) + C, n = 2k

2. T(n)=3T(n 2 ) + n, n = 2k

Solution

1.

Given recurrence is

T(n) = 3T(n/2) +C                               n= 2k

We, can proceed further by replacing T(n/2) with 3T(n/4) + C

T(n) = 9T(n/4) + 3C + C

Next replace T(n/4) by 3T(n/8) + C, to get

T(n) = 27T(n/8) + 9C +3C + C

In general we can write

T(n) = 3iT(n/2i) + 3i-1C + .........+ 3C + C

Given that n= 2k now to reach to T(1), let i = k. Thus, we get

T(n) = 3kT(1) + 3k-1C + .........+ 3C + C

Using formula of geometric progression and putting T(1) = 1, we get

T(n) = 3k + C [(3k - 1)/(3-1)] = 3k + [(3k - 1) / 2] C

Now , k = log2n, thus substituting in above equation we get

Therefore, T(n) = 3log2n + [(3log2n - 1) / 2] C = nlog23 + [(nlog23 - 1) / 2] C

2.

Given recurrence is

T(n) = 3T(n/2) + n                               n= 2k

We, can proceed further by replacing T(n/2) with 3T(n/4) + n/2

T(n) = 9T(n/4) + 3n/2 + n

Next replace T(n/4) by 3T(n/8) + n/4, to get

T(n) = 27T(n/8) + 9n/4 +3n/2 + n

In general we can write

T(n) = 3iT(n/2i) + 3i-1n/2i-1 + .........+ 3n/2 + n

Given that n= 2k now to reach to T(1), let i = k. Thus, we get

T(n) = 3kT(1) + 3k-1n/2k-1 + .........+ 3n/2 + n

Using formula of geometric progression and putting T(1) = 1, we get

T(n) = 3k + n [((3/2)k - 1)/(3/2-1)] = 3k + 2n [(3/2)k - 1 ]

Now , k = log2n, thus substituting in above equation we get

Therefore, T(n) = 3log2n + 2n [(3/2)log2n - 1] = nlog23 + 2n [nlog23/2 - 1] = nlog23 + 2 [nlog23 - n]

Use iteration to find explicit formulas for the following recurrences. For each problem, show your work and draw a recursion tree. Assume T(1) = 1 1. T(n)=3T(n
Use iteration to find explicit formulas for the following recurrences. For each problem, show your work and draw a recursion tree. Assume T(1) = 1 1. T(n)=3T(n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site