Here is the PDF I will referring to.: https://www.docdroid.net/htE62SR/215-216.pdf
The algorithm I'm referring to (which can also be found in the PDF file, above) is the following.:
public static long fibonacciBad(int n) {
if(n <= 1)
return n;
else
return fibonacciBad(n-2) + fibonacciBad(n-1);
}
I'm trying to understand why fibonacciBad is O( 2^(n/2) ), assuming that I'm correct in that being what the PDF is implying.
I suspect that it has to do with using B for every second numbers of calls in A, but the specifics are unclear to me. Also, could someone please give me an intuitive explanation as to why it's okay for it to be every second number of calls in order to be considered exponential (instead of every single number of calls being at least double the previous one)? (I'm making up this alphabetical notation, A and B, for below. This notation isn't used in the PDF linked to here.)
A:
c_0 = 1
c_1 = 1
c_2 = 1 + c_0 + c_1 = 1 + 1 + 1 = 3
c_3 = 1 + c_1 + c_2 = 1+ 1 + 3 = 5
c_4 = 1 + c_2 + c_3 = 1 + 3 + 5 = 9
c_5 = 1 + c_3 + c_4 = 1 + 5 + 9 = 15
c_6 = 1 + c_4 + c_5 = 1 + 9 + 15 = 25
c_7 = 1+ c_5 + c_6 = 1 + 15 + 25 = 41
c_8 = 1 + c_6 + c_7 = 1 + 25 + 41 = 67
B:
1 + 2 + 4 + ... + 2^(n-1) = 2^n - 1