We have the following function which determines the Nth fibonacci number:
int fib(int n){
if(n<=0) return 0;
else if (n==1) return 1;
return fib(n-1)+ fib(n-2)
}
Find the time complexity
I am currently reading the book "Cracking the coding interview" and the answer it gave is quite disappointing. The book says that there are 2 branches per call, and we go as deep as N, therefore the runtime is $O(2^N)$ and it later explains that a tighter upper-bound is $O(1.6^N)$, but it doesn't go over it because the mathematics are "very complex. It doesn't even point out the place where we can find the approach to get the desired upper-bound. I don't want to defame "cracking the coding interview", but I think that more consistency must be shown. My question is, how do we get $O(1.6^N)$ for the algorithm?. It doesn't look like top notch math.