ProgrammingVery hard

A recursive naive Fibonacci fib(n) makes calls(n) = calls(n-1) + calls(n-2) + 1 with calls(0) = calls(1) = 1. Roughly how many calls does fib(40) make?

  1. A. About 3.3 x 10^8
  2. B. About 4 x 10^7
  3. C. About 10^6
  4. D. About 40

Correct answer: A. About 3.3 x 10^8

calls(40) = 331160281. Memoising or iterating reduces the work to O(n), which is why the naive form is too slow.

More C Programming questions

Exams that ask this topic