How explosive is naive Fibonacci?

The naive doubly-recursive fib (with fib(0)=0, fib(1)=1) recomputes everything. Counting the top call and every recursive call, how many calls does it take to evaluate fib(6)?

Show hints (2)+
  1. Each call to fib(n) makes two child calls; count nodes in the call tree.
  2. T(n)=T(n−1)+T(n−2)+1T(n)=T(n-1)+T(n-2)+1, with T(0)=T(1)=1T(0)=T(1)=1.

Answer

Reveal answer →

25

Create a free account to see the full worked solution and track your progress.

Interview format: Hedge Fund Quant, Systematic & Data-Driven Trading

Related questions