Professional Documents
Culture Documents
03 Fall 2014
Recurrence relation
Definition: a recurrence relation is a recursive formula that
counts the number of ways to do a procedure involving n
objects in terms of the number of ways to do it with fewer
objects.
Examples:
= 21
= 1 1 + 2 2 + +
= 1 1 +
, = 1, + 1,1
Fibonacci numbers
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,
Recurrent relation:
= 1 + 2
Initial conditions:
0 = 1
1 = 1
2 = 1 + 0 = 1 + 1 = 2
3 = 2 + 1 = 2 + 1 = 3
8 = 7 + 6 = 21 + 13 = 34
Recurrence relation
Definition: a recurrence relation is a recursive formula that
counts the number of ways to do a procedure involving n
objects in terms of the number of ways to do it with fewer
objects.
We dont know:
We assume we know:
1 , 2 , ,
We want to find:
= 1 1 + 2 2 + + +
Initial conditions
Initial conditions are required to compute , given by some
recurrence relation.
Initial conditions usually are the basic cases of some
procedure and can be computed quickly.
The lowest coefficient in the recurrence relation defines the
number of values required as initial conditions.
For example:
= 1 1 + 2 2 + + +
requires terms as initial conditions.
Example1: Arrangements
Find a recurrence relation for the number of ways to arrange
n distinct objects in a row.
Example1: Arrangements
Find a recurrence relation for the number of ways to arrange
n distinct objects in a row.
= 1 = 1 2 =
= 1 2 2 1 = !
= 1 + 2
Initial conditions: 0 = 1; 1 = 1.
or
1 = 1; 2 = 2.
= 1 +
Initial condition: 0 = 1
= 1 + 1 + 1 = 21 + 1
Initial conditions: 1 = 1
= 2 1
1
1
2
2
3
3
= 1 + 1 + 2 + 2 + 3 + 3
= 21 + 22 + 23
Example9
Find a recurrence relation for the number n-digit ternary
sequences with an even number of 0s.
Example9
Find a recurrence relation for the number n-digit ternary
sequences with an even number of 0s.
2 __ __ __ ... __ look for even number of 0s 1
1 __ __ __ ... __ look for even number of 0s 1
0 __ __ __ ... __ look for odd number of 0s 31 1
Recurrence relation:
= 1 + 1 + (31 1 ) = 1 + 31
Initial conditions:
0 = 1