retagged by
907 views
1 votes
1 votes
T(n) = T(n-1) + T(n-2) + c  i want solve it using substitution method..

T(n) <= 2 T(n-1) + c     is this a correct way ??

plz explain ...

if its wrong then what is correct way
retagged by

2 Answers

1 votes
1 votes
yes u can solve like that.but

use intuition when such kind of qus comes

dnt go for substitution bcz it takes lot of time..
0 votes
0 votes
put m=n-1

T(n-1)=T(m)

=T(m-1)+(m-2)+c

Therefore

T(n)= T(n-1)+

T(n-2)
+c
= T(n-2)+T(n-3)    +

T(n-3) + T(n-4)
+c
=T(n-3)+T(n-3-1) +T(n-3)+

T(n-3)+T(n-3-1)
+c
=3*T(n-3) + 2*T(n-3-1)+c
when base conditions for T(2) and T(1) are  given

we get

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

=(n-2)*T2   +  (n-1)*T1     +c

Related questions

1 votes
1 votes
1 answer
1
0 votes
0 votes
1 answer
2
vivek1211 asked Oct 2, 2023
268 views
T(n) = T(n^1/2) + ndoing this in substitution method gives the ans as O(n)but using tree recursion gives the ans as O(nlogn)which of these are correct and which has to be...
0 votes
0 votes
0 answers
3
rexritz asked Aug 13, 2023
308 views
$T\left ( n \right )= 8T\left ( \frac{n}{2} \right )+\left ( n\cdot logn \right )^{2.99}$Also can $\mathcal{O}(n^{3})$ be an upper bound to above recurrence relation?
1 votes
1 votes
0 answers
4
srestha asked May 19, 2019
639 views
Let $A(n)$ denotes the number of $n$ bit binary strings which have no pair of consecutive $1’s.$ what will be recurrence relation for it and what will be it’s Time Co...