I am reading an analysis of a fibanocci number program, shown below. It is mentioned that this implementation is inefficient. Indeed, the number of recursive calls to compute Fn is F(n+1).
My question is: what does “the number of recursive calls to compute Fn is F(n+1)” mean?
int F(int i)
{
if (i < 1) return 0;
if (i == 1) return 1;
return F(i-1) + F(i-2);
}
The naive implementation to compute fibonacci numbers takes F(n+1) recursive calls to compute the number F(n); i.e. to compute f(10)=55 you need 89 recursive calls, and 89 is F(11).