edited by
782 views
2 votes
2 votes

please tell the time complexity?i was getting O(2n)

edited by

1 Answer

Best answer
5 votes
5 votes

T(n) = 2nT(n-1)

T(n-1) = 2n-1T(n-2)

Similarly, T(n-k) = 2n-kT(n-k-1)

So, T(n) = 2n(2n-1(2n-2..............2n-kT(n-k-1)))

= 2n+(n-1)+(n-2)+......+(n-k)T(n-k-1)

Let, n-k-1=0

So, k=n-1

$\therefore$ T(n) = 2n+(n-1)+(n-2)+......+1T(1) [Substituting k with n-1]

= T(n) = $2^{\frac{n(n+1)}{2}}$ = $\sqrt{2}^{n^{2}+n}$

This is how I did in the test.

selected by

Related questions

0 votes
0 votes
1 answer
1
rajan asked Dec 9, 2016
378 views
how to solve these two using matser thorem.1. t(n)=2t(√n)+n2. t(n)=4t(√n)+(logn)^2
1 votes
1 votes
2 answers
2
vijaycs asked Jul 11, 2016
1,900 views
On which of the following recurrence relation Masters theorem can not be applied ?A. T(n)= 2T(n/2) + n (log n).B. T(n) = T(n/2) + 1.C. T(n) = 8T(n/2) + (log n).D. T(n) = ...
0 votes
0 votes
2 answers
3
0 votes
0 votes
0 answers
4