Class Work 09 Nov 2009

Recurrence Relations

Consider the following recurrence relation:

f(n) = 2 * f(n - 1) + 1, f(0) = 0

Write a recursive function that returns the value of f(n) for a given value of n.

What does f(7) return?

Write another function that returns the value of f(n) for a given value of n using either a while or for loop or a direct algebraic formula.