1. The recursive definition of the Fibonacci sequence (0, 1, 1, 2, 3, 5, 8, 13, ...) is:

f 0 = 0

f 1 = 1

f n = f n - 1 + f n - 2 for n 2

Complete the recursive algorithm that calculates the nth element in the sequence.

2. Complete the recursion tree showing the calls for fib(5).

3. For the fib(5)recursion tree, what would be the maximum number of fib "call-frames" on the "run-time stack" during execution.

4. In the fib(5)recursion tree, number the order in which the calls are performed.

5. Let T(n) represent the time to perform the call to fib(5). Complete the recurrence relation for the fibonacci.

T(n)=

6. Let's investigate how fast does T(n) grows with respect to n's growth?

Complete the inequalities:

(a) (b)

T(n) 2 x T(n-2) T(n) 2 x T(n-1)

7. What makes the recursive Fibonacci calculation so slow?

8. Can you think of a nonrecursive algorithm that would be faster?

9. Let T(n) represent the time to perform the call to your faster algorithm with input n. How fast does T(n) grows with respect to n's growth?