1
$\begingroup$

Consider the following procedure computing a dummy function. Which one is a correct asymptotic bound for the running time of F(N) expressed in terms of N?

F(i):
 if i<3then
 return 0 
 end if
 return F(i−1) + F(i−2)

$• A. O(N) • B. O(N^2) • C.O(2^N) • D. O(N log(N))$


This may seem like a dumb question but I have no idea how to get asymptotic bounds for recursive methods. I got the following recurrence relation: $T(n)=T(n-1)+T(n-2)$ but I'm not sure where to go from here. The answer is supposed to be C.

asked Aug 17, 2018 at 0:47
$\endgroup$
2
  • $\begingroup$ F(1)=0. F(2)=0. F(3)=F(2)+F(1)=0. ....So F(i) = 0 for all i >=0. So the best answer is A. $\endgroup$ Commented Aug 17, 2018 at 2:56
  • $\begingroup$ It showed up on my midterm and the answer was C actually... $\endgroup$ Commented Aug 17, 2018 at 13:12

1 Answer 1

1
$\begingroup$

The recurrence relation $T(n) = T(n-1) + T(n-2),ドル with initial conditions $T(2) = T(1) = 1,ドル has as solution the Fibonacci numbers, whose asymptotic growth is known to be $\Theta(\phi^n),ドル where $\phi = \frac{1+\sqrt{5}}{2} < 2$. The same bound holds for arbitrary positive initial conditions.

answered Aug 17, 2018 at 3:22
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.