[Math] Solving Fibonacci recurrence relation

recurrence-relations

I just started learn how to do data structure and algorithm and i think this is like one of the hardest subject i picked up as compared to doing programming. I have such a hard time understanding hence i do need a little help.

For example, how does this happened?

T(n) = T(n-1) + $n^4$

T(n) = (T(n-2) + $n^4$) + $n^4$

T(n) = ((T(n-3) + $n^4$) + $n^4$) + $n^4$

T(n) = (T(1)) + (n+1)$n^4$

T(n) is in the order of θ(1) + $n^5$ + $n^4$

After the 3rd line of T(n), how did the T(n) after that formulate?

Hence, without understanding that i got problem trying to solve this Fibonacci recurrence relation of

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

By solving this, i should be able to get the upper bound and lower bound complexity of the algorithm. Hence,
I did it by expanding them like this

T(0) = 2 //base condition

T(1) = 2 //base condition

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

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

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

….

T(n) = 2T(n-k) + kc

Then i'm stuck at this. Any assistance on that ?

Best Answer

Hint

Actually, you are not having the right understanding. One way to deal with your question is:

$$T(n)=2T(n-1)+c\quad(1)$$

then

$$T(n+1)=2T(n)+c\quad(2)$$

so $(2)-(1)$

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

now call $a(n)=T(n)-T(n-1)$ then you get

$$a(n+1)=2a(n)$$

which is a geometric sequence.

and also

$$\sum_{i=1}^{n}a(i)=T(n)-T(0)$$

Can you finish?

Related Question