« Time complexity for Fibonacci function

Time complexity for Fibonacci function

fibonacci.jpg

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

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

...

Solving above equations will be pretty difficult so lets draw recursion graph and lets try to get out time complexity from there.

fibonacci_time_complexity.jpg

Each of the steps does nothing. They just call further steps and does some k total work. So all the steps will do some k work. In total we have 2n steps. So total time complexity will be k(2n).

T(n) = O(2n)