Section 2.4: Recursion
Abstract:
In this section we examine the definition and multiple applications of
recursion, and encounter many examples. We also solve one types of linear
recurrence relation to give closed-form solutions.
A recursive definition is one in which
-
A basis case (or cases) is given, and
-
an inductive or recursive step describes how to generate additional cases.
Example: the Factorial function sequence:
-
F(0)=1, and
-
F(n)= nF(n-1).
Note: This method of defining the Factorial function obviates the need
to ``explain'' the fact that F(0)=0!=1. For that reason, it's better than
defining the Factorial function as ``the product of the first n positive
integers,'' which it is from n=1 on....
In this section we encounter examples of several different objects which are
defined recursively (See Table 2.5, p. 131):
Vocabulary:
-
linear recurrence relation: S(n) depends linearly on previous S(r),
r<n:
(Note: I've changed the indices from the book, to make them line up with
the arguments to S.) The relation is called homogeneous if g(n)=0.
(Fibonacci is a homogeneous linear recurrence relation, as is factorial.)
-
first-order: S(n) depends only on S(n-1), and not previous terms
(Fibonacci is second-order, depending on the two previous terms;
factorial is first-order.)
-
constant coefficient: In the linear recurrence relation, when the
coefficients of previous terms are constants.
(Fibonacci is constant coefficient; factorial is not.)
-
closed-form solution: S(n) is given by a formula which is simply a
function of n, rather than recursive.
(Both Fibonacci and factorial have closed-form solutions.)
The author suggests an ``expand, guess, verify'' method for solving recurrence
relations.
Example:
-
Practice 11, p. 121
-
Practice 19, p. 128
-
Practice 21, p. 133
Example: general linear first-order recurrence relations with constant
coefficients.
``Expand, guess, verify''!
LONG ANDREW E
Tue Feb 12 19:32:48 EST 2002