I have seen a solution for it but I was confused at the end.
this is the solution by Siddharth Chakravorty
T(n)=2T(n-1)+n -----(1) T(n-1)=2T(n-2)+n-1 ------(2) T(n-2)=2T(n-3)+n-2 ------(3)
Substitute (3) in (2) and then (2) in (1)
T(n-1)=22T(n-3)+2(n-2)+(n-1)
T(n)= 23T(N-3)+22(n-2)+2(n-1)+n
=> T(k)=2kT(n-k) + 2k−1(n-(k-1))+........+20n
Now, since T(1)=1, let n-k=1 => k=n-1
T(n)=2n−1T(1) + 2n−2(2) + 2n−3(3) + 2n−n(n) --------(4)
Multiply Equation (4) with 2
T(n)=2n+2n−1 + 2n−2 + 2n−3+...... + 2n ----------- (5)
Subtract Equation (5) with (4)
T(n)=2n+2n−1+2n−2+2n−3+........+2 -n
Using sum of GP terms, we get :
[ 21(2n-1) - n ]/ (2-1)
= 2n+1 -2 -n
I am stuck at subtraction of 5 and 4 equations. And does it affect the answer if value of n is given(n>=2) or not?? can anyone explain it ??