Title: Chapter 6 Advanced Counting
1Chapter 6Advanced Counting
2Recurrence Relations
Definition An equation that expresses the
element an of the sequence an in terms of one
or more previous terms of the sequence
a0,...,an-1. A sequence is a solution of the
recurrence relation if its terms satisfy the
recurrence relation.
Example Consider the recurrence relation an
2a(n-1) a(n-2), n in N Consider the sequence
an3n. Is it a solution? ? 2x3x(n-1)-3x(n-2) 3n
YES! (a0 0, a1 3, a2 6,...) Consider the
sequence an5. Is it a solution? ? 2x5 5 5
YES! (a0 5, a1 5, ...) we see that to
sequences can be a solution of the same
recurrence relation since the initial conditions
are also very important. The initial conditions
plus the recurrence relation provide a unique
recursive definition of a sequence.
3Modelling
Lets say you put 1 dollar in the bank now. How
much will you receive in 50 years if the interest
is 4? B(0) 1. B(n) B(n-1) 0.04xB(n-1)
(add the interest). 1.04 x B(n-1).
1.042 B(n-2) 1.0450 B(0)
7.1
4Tower of Hanoi
How many moves does it take to solve the Hanoi
puzzle?
Let Hn be the number of moves to solve a problem
with n disks. -We first move the top n-1 disks to
peg 2 in H(n-1) moves. -We then move the largest
disk to peg 3 in 1 move. -We then move the n-1
disks on top of the largest disk in another
H(n-1) moves ? Total Hn 2xH(n-1)1 -Basis
Step 1 disk 1 move H(1)1. -Hn
2(2H(n-2)1)1 22H(n-2)21
1 .... 2(n-1)H1 2(n-2) 2(n-3)...21 2n
-1 (by sums of geometric series 3.1).
5Examples
How many bit-strings of length n with no
consecutive 0s? ? an is number of bit-strings
with no 2 consecutive 0s in it. How can we
generate a bit-string of length n from
bit-strings of length n-1? Valid bit-strings
fall into 2 classes, ones that end with a 0 and
ones that end with a 1. Ones that end in a
1 could be generated by adding a one to a valid
bit-string of any kind a(n-1) ways. Ones that
end with a 0 came about by appending a smaller
bit-string of length n-1 that ended with a 1
(otherwise 2 zeros appear), which must have come
about in turn by appending a 1 to any valid
bit-string of length n-2 a(n-2) ways. Total an
a(n-1) a(n-2) ngt2. a1 2, a2
3. Recognize it? 2,3,5,8,13.....?
6Catalan Numbers
In how many ways Cn can we put parentheses around
n1 symbols to indicate in which order they
should be processed? ? Each string x0 x1 x2 ...
xn is divided into 2 sub-strings e.g. ((x0 x1)
x2) (x3 x4) Assume break occurs at after position
k, then there are Ck x Cn-k-1 ways to
put parenthesis around the first second
sub-string. Thus the total is Cn C0 Cn-1
C1Cn-2 ... Cn-1C0 with C01 and C1 1.
(derivation later)
number of extended binary trees with n internal
nodes.
2
5
14