Back

Question: 2013 Fall Midterm - 13

Author: Pat Morin
Consider the recursive algorithm $\Fib$, which takes as input an integer $n \geq 0$:

$\mathbf{Algorithm}\ \Fib(n)\mathrm{:}$
$\mathbf{if}\ n = 0\ \mathrm{or}\ n = 1$
$\mathbf{then}\ f = n$
$\mathbf{else}\ f = \Fib(n - 1) + \Fib(n - 2)$
$\mathbf{endif};$
$\mathbf{return}\ f$

For $ n \geq 2 $, run algorithm $ FIB(n)$ and let $ a_n $ be the number of times that $ FIB(0) $ is called.
(a)
$a_n = f_{n+1}$
(b)
$a_n = f_n$
(c)
$a_n = f_{n-1}$
(d)
$a_n = f_n - 1$