Given that fib$(n)$=fib$(n-1)$+fib$(n-2)$ for $n>1$ and given that fib$(0)=a,$ fib$(1)=b$ $($some $a, b >0)$ which of the following is true?
fib$(n)$ is :
Select one or more:
a. $O(n)$
b. $O(n^2)$
c. $O(2^n)$
d. Answer depends on $a$ and $b$.
e. $O(({1 + \sqrt 5}/2)^n)$
f. $O(({1 - \sqrt 5}/2)^n)$
Here what I think,
fib$(2) = (a) + (b) = a + b$
fib$(3) = (a + b) + (b) = a + 2b$
fib$(4) = (a + b + b) + (a + b) = 2a + 3b$
fib$(5) = (a + b + b + a + b) + ( a + b + b) = 3a + 5b$
fib$(6) = 5a + 8b$
fib$(7) = 8a + 13b$
How exactly do I generalize in terms of $n$, so that I can find out the Worst case?
The Time complexity of $fib(n)$ is asymptotically the same as value of $fib(n)$, because $T(fib(n))=T(fib(n-1))+T(fib(n-2))$, so you can create a generating polynomial for it, and see that the right answer is e.