Professional Documents
Culture Documents
1. Express the recurrence as a single equation/formula. Define a sequence hrn i corresponding to the
recurrence.
2. multiply rn by xn and sum it up for all integers n. Plug in the right hand side of the recurrence in
place of rn and do some manipulations. This gives the generating function R(x) for hrn i.
3. Usually R(x) = P (x)/Q(x) where P (x) and Q(x) are polynomials. One has to make use of partial
fractions and standard mathematical tools to express R(x) in such a form that you can easily extract
{xn }R(x) from it.
If G(x) is generating function for sequence hgn i, then xi0 G(x) is generating function for the sequence
hhn i where hn = gni0 for all n.
a X m + n
= abn xn
(1 bx)m+1 n
n0
1
2.2 Generating function for Fibonacci numbers
Recall that we derived the following recurrence for the Fibonacci numbers
fn = fn1 + fn2 + [n = 1]
Hence generating function F (x) for the sequence of Fibonacci numbers is obtained as follows.
X
F (x) = fn xn
n
X
= (fn1 + fn2 + [n = 1])xn
n
X X X
= fn1 xn + fn2 xn + [n = 1]xn
n n n
2
= xF (x) + x F (x) + x
Hence generating function T (x) for the sequence htn i can be obtained as follows.
X
T (x) = tn xn
n
!
X X X
= ti tn1i xn + [n = 0]xn
n i n
X X
n
= hn1 x + 1 where hm = ti tmi
n i
= xH(x) + 1
where H(x) is generating function for hhn i. Now observe that hhn i is convolution of htn i and htn i. Hence,
using the product rule mentioned in the previous lecture, H(x) = T (x)2 . Plugging this expression for H(x)
in the above equality and doing simple manipulations, we get
1 1 4x
T (x) =
2x
1 2n
It was left as a homework exercise to infer that {xn }T (x) is n+1 n .
2
3 Solving an interesting counting problem using recurrences and
generating functions
The counting problem of this lecture is defined for a fan which is an undirected unweighted graph defined as
follows. For any positive integer n, a fan of order n is a graph on n + 1 vertices and 2n 1 edges as follows.
The vertex set is {0, 1, ..., n}, and the edge set is {(0, i)|1 i n} {(i, i + 1)|1 i < n}.
Figure 1 gives a pictorial description of a fan of order 7.
0
1 2 3 4 5 6 7
Let Sn be the set of spanning trees of fan graph of order n, and let tn = |Sn |. It is easy to observe that
t0 = 0 since the number of edges 2n 1 is -1 for n = 0, so fan graph of order 0 is not even defined, and so
t0 = 0. It is also easy to observe that t1 = 1.
we shall now devise two solutions for calculating tn for any n > 0. Both of them first devise a recurrence
for tn .
4 Solution 1
4.1 finding a recurrence of tn
This solution is based on the following key idea about the spanning tree.
Consider the vertex n. It has 2 edges incident on it. Certainly it must have at least one of these edges in
the spanning tree. This implies that if (0, n) is not in a spanning tree of Fn , then the other edge (n 1, n)
must be there in the spanning tree. This observation motivates us to partition the set Sn of spanning trees
into the following 2 categories.
1 2 n
spanning tree from Sn1
3
2. The set of spanning trees in which (0, n) is present :
In this case, we cant say whether the edge (n 1, n) is or is not necessarily present in the spanning
tree. All such spanning trees can be categorized into the groups as shown in Figure 3. Hence the
0 0 0
1 2 n 1 2 n 1 2 n
spanning tree from Sn1
spanning tree from Sn2
number of spanning trees of fan of order n where edge (0, n) is present is equal to
1 + t1 + ...tn2 + tn1
Combined together the above two cases, we get the following recurrence which holds for each value of n.
X
tn = ti + tn1 + [n > 0] (1)
i<n
Hence we get the following equation which governs the generating function T (x) for the sequence < tn >.
Hence
x
T (x) =
1 3x + x2
As a homework, try to get an expression for tn from the above generating function.