Sie sind auf Seite 1von 36

Discrete Math by R.S. Chang, Dept.

Information Management, NTIT 1


Chapter 10
a
0
a
1
a
2
a
n
a
n-1
a
0
=0
a
1
=2
a
2
=6
a
3
=12
a
4
=20

Discrete Math by R.S. Chang, Dept. Information Management, NTIT 2


Chapter 10
10.1 The First-Order Linear Recurrence Relation
geometric progression
If is a geometric progression, then
the common ratio.
For example, (or
+ +
a a a
a
a
a
a
a
a
a
a
r
a a n a a
n
n
n n n n
0 1 2
1
0
2
1
3
2
1
1 1
3 0 3 0
, , ,
,
, . )

= = = = = =
= > =
+
a first-order, linear, and homogeneous recurrence relation
(difference equation) with constant coefficient
The arithmetic progression
a a
n n +
= +
1
3
is nonhomogeneous.
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 3
Chapter 10
10.1 The First-Order Linear Recurrence Relation
There are many sequences that satisfy
a a n
n n +
= >
1
3 0 , .
For example, 5,15,45,135,... or 7,21,63,189,.... To pinpoint
the particular sequence described, we need to know one of the
terms of the sequence. (boundary condition, or initial condition
since usually a
0
is specified)
a a n a
n n +
= > =
1 0
3 0 5 , ,
determines the sequence 5,15,45,135,...
The general solution of the recurrence relation
is a constant, and is unique and is given by
+
0
a da
n d a A
a Ad n
n n
n
n
1
0
0
=
> =
= >
,
, ,
, .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 4
Chapter 10
10.1 The First-Order Linear Recurrence Relation
Ex. 10.2 A bank pays 6% (annual) interest on savings, compounding
the interest monthly. If Boonie deposits $1000 on the first day of
May, how much will this deposit be worth a year later?
Let p
n
denote the value of deposit at the end of n months.
Then p
n+1
=p
n
+(6%/12)p
n
=1.005p
n
. With p
0
=$1000, we have
p
n
=p
0
(1.005)
n
. The answer is p
12
=$1000(1.005)
12
=$1061.68.
A nonlinear recurrence relation
Ex. 10.3 Find if = , where > 0 for 2, and = 2.
Let = . Then and
12 + 0
+ 0
a a a a n a
b a b b b
n n n
n n n n
1
2 2
2
1
5
5 4
>
= = .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 5
Chapter 10
10.1 The First-Order Linear Recurrence Relation
nonhomogeneous linear recurrence relation
Ex. 10.4 time complexity of bubble sort algorithm
a
n
=a
n-1
+(n-1), n>1, a
1
=0, where
a
n
=the number of comparisons to sort n numbers
a
n
- a
n-1
= n-1
a
n-1
- a
n-2
= n-2
a
n-2
- a
n-3
= n-3

a
2
- a
1
= 1
+
a
n
=1+2+3+...+(n-1)=(n
2
-n)/2
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 6
Chapter 10
10.1 The First-Order Linear Recurrence Relation
find the recurrence pattern
Ex. 10.5
a
0
=0
a
1
=2
a
2
=6
a
3
=12
a
4
=20

a
1
- a
0
=2
a
2
-a
1
=4
a
3
- a
2
=6
a
4
- a
3
=8
a
n
- a
n-1
=2n

+
a
n
=n
2
+n
nonconstant coefficients
Ex. 10.6
a n a
n a
a n
n n
n
=
> =
=
1
1
,
.
!.

where 1 and
The answer is
0
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 7
Chapter 10
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
The equation:
substituting where 0 and 0, into the recurrence
relation, we obtain With
, 0, this becomes which is called
the of the recurrence relation.
C a C a C a n
a cr c r
C cr C cr C cr
c r C r C r C
characteristic equation
n n n n n n
n
n
n
n
n
n
n
n
n n n
+ + = >
= = =
+ + =
= + + =



1 1 2 2
1
1
2
2
2
1 2
0 2
0
0
, ,
,
.
,
three cases for the characteristic roots:
(a) distinct real numbers
( , ): r r a c r c r
n
n n
1 2 1 1 2 2
= +
(b) complex conjugates
(c) duplicate roots
( , ): r r a c r c r
n
n n
1 2 1 1 2 2
= +
( , ): ( ) r r a c c n r
n
n
1 1 1 2 1
= +
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 8
Chapter 10
Case (A): distinct real roots
Ex. 10.8 where 2 and
Characteristic equation: ( + )( - 2) = 0,
with
is the unique solution.
Ex. 10.9 (Fibonacci relation) where 0,
and
Let The c. e. is with root
1 5
2
The general solution is
0
0
+
0
2
1
a a a n a a
r r r r
a c c a a c c
a
F F F n
F F
F cr r r
c
n n n
n
n n
n
n
n n n
n
n
+ = > = =
+ =
= + = = = =
=
= + >
= =
= =

+

+
1 2 1
2
1 2 1 1 2
2 1
1
6 0 1 2
6 0 3
2 3 1 2 1 0
2
0 1
1 0
1 5
2
, , .
,
( ) , , , ,
,
, .
. .
|
\

|
.
|
+
|
\

|
.
|
= = =
+ |
\

|
.
|

|
\

|
.
|

(
(
n n
n
n n
c
F F F
2
1
1 5
2
0 1
1 5
2
1 5
2
.
, , With
1
5
0
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 9
Chapter 10
Case (A): distinct real roots
Ex. 10.10 For 0, let ={1,2,3, , } (when = , = ),
and let denote the number of subsets of that contain no
consecutive integers. Find and solve a recurrence relation for
If and is to be counted in there are two possibilities:
(a) : When this happens ( - ) , and - { } would be
counted in (In other words, for all sets counted in
we can add to that set for it to be counted in
(b) : is also counted in
Therefore, (Fibonacci relation!). Together with
( ) and
.
-2 -2
-
0
n S n n S
a S
a
A S A a
n A n A A n
a a
n a
n A A a
a a a
a a
n
n
n
n n
n
n
n n n
>
_
e e
e
= +
=

0
1
1
1
1 2
|
|
,
. ,
.)
.
1
( ,{1}), we have
0.
=
=
+ |
\

|
.
|

|
\

|
.
|

(
(
>
+ +
2
1
5
1 5
2
1 5
2
2 2
|
a n
n
n n
,
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 10
Chapter 10
Case (A): distinct real roots
Ex. 10.11 number of legal arithmetic expressions, without
parentheses, that are made up of the digits 0,1,2,...,9 and the binary
operator +,*,/.
Let a
n
be the number of expressions made up of n symbols. Then
a
1
=10 (0,1,...,9), a
2
=100 (00,01,...,99). For n>2, two cases:
(a) the last two symbols are digits: remove the last digit, we have a
legal expression for a
n-1
. (10a
n-1
)
(b) the last two symbols are operator and digit: remove the two
symbols, we have a legal expression for a
n-2
(29a
n-2
, no /0)
Therefore, a
n
=10a
n-1
+29a
n-2
, and a
1
=10, a
2
=100.
( ) ( )
a n
n
n n
= +

(
>
5
3 6
5 3 6 5 3 6 1 , .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 11
Chapter 10
Case (A): distinct real roots
Ex. 10.13 Find a recurrence relation for the number of binary
sequences of length n that have no consecutive 0's.
Let a
n
be the number of such sequences with length n,n>0.
Then a
1
=2, a
2
=3. There are two cases for a
n
:
(1) the nth symbol is 1: the preceding n-1 symbols sequence is
counted in a
n-1

(2) the nth symbol is 0: a
n
ends in 10 and the preceding n-2 symbols
sequence is counted in a
n-2
.
Therefore, a
n
=a
n-1
+a
n-2
.
a n
n
n n
=
+ |
\

|
.
|

|
\

|
.
|

(
(
>
+ +
1
5
1 5
2
1 5
2
2 2
, 0
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 12
Chapter 10
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
Be careful not to draw conclusions from a few (or even,
perhaps, many) particular instances.
Ex. 10.14 Arrange pennies contiguously in each row where each
penny above the bottom row touches two pennies in the row
below it.
a
1
=1,a
2
=1,a
3
=2,a
4
=3,a
5
=5,a
6
=8,... Is a
n
=F
n
? NO
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 13
Chapter 10
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
extend to higher order
Ex. 10.15 2
The C. E. is 2
From
we have
+
3
a a a a n a a a
r r r r r r
a c c c a a a
c c c
n n n n
n
n n
n
3 2 1 0 1 2
2
1 2 3 0 1 2
1 2 3
2 0 0 1 2
2 1 0 2 1 1 1
1 1
1
2
0 1 2
5
2
1
6
8
3
= + > = = =
+ = = +
= + +
|
\

|
.
|
= = =
= = =
+ +
, , , , .
( )( )( ).
( ) ( ) . , , ,
, , .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 14
Chapter 10
10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients
Case (b) Complex Roots
DeMoivre's Theorem
(cos sin ) cos sin , .
(cos sin )
(cos sin )
u u u u
u u
u u
+ = + >
e =
+
+
+
+
|
\

|
.
|
|
= +
= +
i n i n n
z x iy z
z x y
x
x y
i
y
x y
r i
z r n i n
n
n n
0
2 2
2 2 2 2
If = + C, 0, then
=
x
y
x y
2 2
+
u
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 15
Chapter 10
Case (b) Complex Roots
( )
( )
( )
Ex. 10.17
The C. E. is with roots 1 i.
2
a a a n a a
r r
a c i c i c i
c i c
n
i
n
c
n
i
n
c c
n
i
n n n
n
n n
n
n
n
n
n
= > = =
+ =
= + + = +
|
\

|
.
|

(
+

|
\

|
.
|

(
= +
|
\

|
.
|
+

|
\

|
.
|
=
+ +

2 2 1 2
2 2 0
1 1 2
4 4
2
4 4
2
4 4
2
4 4
2
4
1 2 0 1
1 2 1
2 1
2
1 2
( ), , , .
( ) ( ) cos sin
cos sin cos sin
cos sin
( ) cos (
t t
t t t t
t t
t
( )
c c
n
a a
c c c c i
a
n n
n
n
1 2 0 1
2 1 2
4
1 2
1
2
4 4

(
= =
+ = =
= +
|
\

|
.
|
) sin . , ,
.
cos sin .
t
t t
With
we have and Therefore,
1
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 16
Chapter 10
Case (b) Complex Roots
Ex. 10.18 For R consider the determinant given by
+
b n n D
b b
b b b
b b b
b b b
b b b
b b b
b b b
b b b
b b
n
e ,
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0

=bD
n-1
-b
2
D
n-2
D b
n n
n
n
= +

(
cos sin
t t
3
1
3 3
D b b D
b b
b b
1 2
0 = = = = | | and
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 17
Chapter 10
Case (c) Repeated Real Roots
Ex. 10.19 where 0 and
The C. E. is Since it has only one root with
multiplicity 2, to have two linear independent solution, let' s
try With and we have
In general, the solution corresponds to a root with multiplicity
has the form (
0 1
0
a a a n a a
r r
a c c n a a
a n n
r
m A A n A n A r r
n n n
n
n n
n
n n n n
m
m n
+ +


= > = =
+ =
= + = =
= + = +
+ + + +
2 1 0 1
2
1 2
1
1 2
2
1
1
4 4 1 3
4 4 0
2 2 1 3
2
1
2
2 2 2
, , .
.
. ,
.
) .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 18
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
C a C a C a f n
a a a a
a
C a a C a a
C a a C a C a C a
C
n n n n n n
n n
h
n
p
n
h
n
p
n n
h
n
p
n
n
h
n
p
n
n
h
n
p
n n
h
n
n
h
n
n
h
n
+ + =
= +
+ + + +
+ = + + +






1 1 2 2
1
1 1
2
2 2
1
1
2
2
( )
,
( ) ( )
( ) ( )
(
( ) ( )
( ) ( ) ( ) ( )
( ) ( )
( ) ( ) ( )
Let where denotes the general solution
of the corresponding homogeneous solution and denotes
a solution of the given nonhomogeneous solution (particular
solution). Then
( )
( )
a C a C a f n f n
a a a
n
p
n
n
p
n
n
p
n n
h
n
p
( )
( ) ( )
( ) ( )
) ( ) ( ), + + = + =
= +




1
1
2
2
0 which
indicates that is indeed a general solution.
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 19
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.22 where 1 and
Since ( ) = 5(7 let which
leads to ( So =
35
4
and
The general solution
With = -
27
4
0
n ( )
( )
a a n a
a c f n a A
A A A
a a c
a c
n n
n
n
h n
n
p n
n n n
n
p
n
n
n
n
= > =
= =
=
= = +
=

+ +
3 5 7 2
3 7
7 3 7 5 7
5 7
4
3
5 7
4
2
1
1
1 1
0
( ), .
( ). ), ( ),
) ( ) ( ).
( )
. ( )
( )
.
, .
( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 20
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex 10.23
and since 3 is a characteristic root,
Substitute into the given relation yields
or - ( - ) =5, so =5.
Hence With
Ex. 10.24 The Tower of Hanoi Problem
= the number of moves required for disks.
and
( )
( )
+
a a n a
a c a Bn
a
Bn B n Bn B n B
a c n a c
a n
a a a
a c a
n n
n
n
h n
n
p n
n
p
n n n
n
n
n
n n
n
h n
n
= > =
= =
=
= + = =
= + =
=

3 5 3 1 2
3 3
3 3 1 3 5 3 1
5 3 2 2
2 1 0
2
1 0
1
0
1 0
( ), , .
( ), .
( ) ( ),
( ) . , .
.
( ),
( )
( ) ( p n
n
n
A
a
)
( )
.
=
=
1
2 1
n+1 disks
peg 1 peg 2 peg 3
move to
rule: one disk at a time
larger one must not on top of a smaller one
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 21
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.25 Pauline takes out a loan of S dollars that is to be paid
back in T periods of time. If i is the interest rate per period for the
loan, what constant payment P must she make at the end of each
period?
a
n
:the amount still owed on the loan at the end of the nth
period (following the nth payment)
| |
a a ia P n T a S a
a c i a A
A
P
i
a S
P
i
i
P
i
a S
P
i
i
P
i
P Si i
n n n T
n
h n
n
p
n
n
T
T
T
+


= + s s = =
= + =
= =
|
\

|
.
|
+ +
=
|
\

|
.
|
+ +
= +
1 0
1
0 1 0
1
1
1
1 1
, , , .
( ) , .
, ( ) .
( ) ,
( ) ( ) .
( ) ( )
Since 0 =
Example:
S=5,000,000
i=10%/12
T=20 years=240 months
P=48251
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 22
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.27 The snowflake curve
a
0
3
4
=
area:
1
1
1
3
2
a
1
2
3
4
3
3
4
1
3
= +
|
\

|
.
|
a a
2 1
2
2
4 3
3
4
1
3
= +
|
\

|
.
|

(
(
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 23
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.27 The snowflake curve
| |
a a a
a A A a B
a
a
n n
n
n
n
n
n
h n
n
p
n
n
n
n
n
n
n
+
+

= +
|
\

|
.
|
|
\

|
.
|
= +
|
\

|
.
|
= = =
|
\

|
.
|
=
|
\

|
.
|

(
(
= = +
|
\

|
.
|
= +

1
1
2
1
0
4 3
3
4
1
3
1
4 3
4
9
1
4
9
1
5 3
6
4
9
6
5 3
3
4
1
4 3
4
9
3
4
1
4 3
1
1
4
9
( )
( ) ,
.
lim
( ) ( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 24
Chapter 10
f n a
c A
n A n A
n A n A n A
n t A n A n A n A
r r R Ar
n A n B n
n A n B n
n r r A n A n A n A
r n r
n
p
t
t
t
t
t
n n
t n n
t
t
t
t
n
( )
,
,
sin sin cos
cos sin cos
( )
sin

a constant , a constant


, Z

+
+


( )
+
1 0
2
2
2
1 0
1
1
1 0
1
1
1 0
+
+ +
e + + + +
e
+ + + +

o o o
o o o
o
n
n n
A n B n
r n r A n B n
( sin cos
cos sin cos
o o
o o o
+ )
( + )
Summary
1. Linear combinations work.
2. If f(n) contains r
n
and r is a characteristic root of multiplicity k,
then multiply by n
k
.
r=1
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 25
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.30 For n>1 suppose that there are n people at a party and
that each of these people shakes hands (exactly one time) with all
of the other people there (and no one shakes hands with himself
or herself). If a
n
counts the total number of handshakes, then
a
n+1
=a
n
+n, a
2
=1, n>1, because when the (n+1)th person arrives,
he or she will shake hands with the n other people already arrived.
a c c
a n A n A
a
n n
n
n
h n
n
p
n
( )
( )
( )
( )
( )
= =
= +
=

=
|
\

|
.
|
1
1
2 2
1 0
The result is
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 26
Chapter 10
10.3 The Nonhomogeneous Recurrence Relation
Ex. 10.31
( )







+
( )
a a a f n n
a c c
f n a
A
n A n A n A
A
r r A r
A n
A n A
A n A n
n n n
n
h n n
n
p
n n
n n
n n
n n n n
n n n n
2 1
1 2
0
2
3
2
2 1
4
5
6
7 8
9 10
10 21 0
3 7
5
3 2
7 11 11
31 3 7
6 3 3
2 3 8 9 3 9
4 3 3 7 3 7
+ = >
= +
+ +
=
+
+ +
+
( ),
( )
, ,
( )
( ) ( )
( ) ( )
( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 27
Chapter 10
10.4 The Method of Generating Functions
Ex. 10.32
Let ( ) =
a a n n a
a x a x nx
a x a x nx
f x a x
f x a xf x
x
x
f x
x
x
x x
x x
x
a
n
n n
n
n
n
n n
n
n
n
n
n n
n n
n
n
n
n
n
= > =
=

+

=

= +

+
+

3 1 1
3
3
3
1
1
1 3
1 1 3
7 4
1 3
1 4
1
1 2
1
7 3
4
1
4
1
2
1 0
1
1
1
1 1
0
0
2
2 2
, , .
( ) ( )
( )
( )
( ) ( )
/ / /
( )
( ) ( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 28
Chapter 10
10.4 The Method of Generating Functions
Ex. 10.33
+
a a a n a a
a x a x a x x
a x a x a x x
f x a a x x f x a x f x
x
x
f x
x x
x x
n n n
n
n
n
n
n
n n
n
n
n
n
n n
n
n
n
n
n
2 1 0 1
2
2
1
2 2 2
2
2
1
2
0 0
2
0
2
0
0 1 0
2
2
2
5 6 2 0 3 7
5 6 2
5 6 2
5 6
2
1
10 11 3
1 1 2
+ = > = =
+ =


+

=

+ =

=
+

+
+
+
+
+ + +
+
+
+
+
=

+
=

+
=

, , , .
( ( ) ) ( ( ) ) ( )
( )
( )( )(1 3
2
1 3
1
1
2 3 1 0

= + >
x x x
a n
n
n
)
( ) , .
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 29
Chapter 10
10.4 The Method of Generating Functions
Ex. 10.35 a
Let
n+1
= + = + = =
=

=

= +

= +

= + = +
=

+
=

+
+
=

+ +
=

+
+
=

+ +
=

2 1 0
2
2
1
1 0 0
0 0
1
1
0
1 1
0 0
1
1
0
1 1
0 0
0 0
a b b a b a b
f x a x g x b x
a x a x b x
b x a x b x
f x a xf x xg x g x b xf x xg x
f x
x
n n n n n
n
n
n
n
n
n
n
n
n
n
n
n
n
n n
n
n
n
n
n
n
n
n n
, , ,
( ) , ( )
( ) ( ) ( ), ( ) ( ) ( )
( )
x x
g x
x
x x
2 2
3 1 3 1 +
=
+
, ( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 30
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
If ( ) = is the generating function for
then generates
the convolution of the sequence with itself.
Ex. 10.36 Count the number of rooted ordered binary trees
on vertices. For = 3, there are 5 trees.
0
0
0
f x a x a a
f x a a a a a a a a a a a a
a a
n n
i
i
i=

+ + +
0
1
2
0 0 1 1 0 0 2 1 1 2 0
1
, , ,
( ) , , ,
, , ,


Discrete Math by R.S. Chang, Dept. Information Management, NTIT 31
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)
select one as root
for n+1 vertices:b
n+1
b
0
b
n
b
1
b
n-1
b
n
b
0


Hence, for 0,
So
+
n
b b b b b b b b b
b x f x b
b b b b b b b b x
xf x f x
x
x
n n n n n
n
n
n
n n n n
n
n
>
= + + + +

= =
+ + + +

= =


+
+
=


+
=

1 0 1 1 1 1 0
1
1
0
0
0 1 1 1 1 0
1
0
2
1 1 4
2

( )
( )
( ) ( )
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 32
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)
( ) 1 4 1 4
1 2
4
1
2
4
1
2
1
2
1
1
2
2
1
2
1
4
1
1
2
1
2
3
2
2 3
2
1 4
1 2 1 3 2 3
1 2 1 3 2 3 2 1
2 1
1 2
0
1
= =
|
\

|
.
|

|
\

|
.
|
|
=

|
\

|
.
|

|
\

|
.
|
+
|
\

|
.
|

=



=

=

x x
n
x
n
n
n
n
n
n
n
n n n
n n n
n
n
n n
n n n
n
n
/
/
( )
( )
!
( )
( ) ( )
!
( ) ( )
!
( ) ! ( ) ( )
! !(

)
( )( )!
( ) ! !
=

|
\

|
.
|
1 2
2 1
1
2 1
2
n
n n n
n
n
n
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 33
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.36 (continued)
f x
x n
n
n
x
b x
n
n
n
x
b
n
n
n n
n
n
b
n
n
n
n n
n
n
n
( )
.
( )
( )
=

|
\

|
.
|

|
\

|
.
|

=
+

+
+
|
\

|
.
|
=
+
|
\

|
.
|
=

1
2
1 1
1
2 1
2
1
2 1
2
1
2
1
2 1 1
2 1
1
1
1
2
1
1
1
and is half the coefficient of in
So
is called the Catalan number.
+
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 34
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n.
stack
1,2,...,n input output
We can generate 1,2 or 2,1 from 1,2.
We can not generate 3,1,2 from 1,2,3.
Let a
n
count the number of ways to
permute 1,2,...,n using this method.
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 35
Chapter 10
10.5 A Special Kind of Nonlinear Recurrence Relation
Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n.
Suppose the output list for 1,2,...,n,n+1is:
1
j numbers k numbers j+k=n
0 n
1 n-1

n 0
= + + + + =
=
+
|
\

|
.
|
+
a a a a a a a a a a
a
n
n
n
n n n n n
n
1 0 1 1 1 1 0 0
1
1
1
2
,
Discrete Math by R.S. Chang, Dept. Information Management, NTIT 36
Chapter 10
Exercise:P423:10
P432,433:1,6
P444: 12
P457: 6

Das könnte Ihnen auch gefallen