these example problems

advertisement
Upenn 340 – Preparation for the final
Per Alexandersson
Things you should know
Linear recurrences — homogeneous and non-homogeneous. Solve systems
of linear recurrences. The relationship between the characteristic polynomial and the general solution. Find the generating function for a sequence
satisfying a linear recurrence. Be familiar with the generating function
for the number of integer partitions and related sequences. Be able to do
inclusion-exclusion arguments. Write down a generating function given a
text description. Find coefficients of xn in a generating function. Be able to
prove/explain recurrences (Catalan, set partitions, etc.) using a combinatorial argument.
New problems
Example 1. A certain generating function T (x) satisfies T (x) = xT (x)3 + 1.
Find the coefficient of x0 , x1 and x2 of T (x).
Hint: Put T (x) = a0 + a1 x + a2 x2 + · · · and plug into the equation.
Example 2. Let zn be the number of words of length n with letters in
{a, b, c, d} where b appears an odd number of times in the word.
1. Find a recurrence relation for zn , and determine the initial conditions.
2. Solve the recurrence.
Hint: For the first part, use the fact that 4n − zn is the number of “bad”
words of length n.
1
Example 3. Let an be the number of strings on the alphabet {0, 1, 2}, such
that the number of 1’s plus the number of 2’s is even. Find the generating
function for an , and give a closed-form formula for an .
Example 4. (From China Girls MathOlympiad 2004)
A deck of 32 cards has 2 different jokers each of which is numbered 0.
There are 10 red cards numbered 1 through 10 and similarly for blue and
green cards. One chooses a number of cards from the deck. If a card in hand
is numbered k, then the value of the card is 2k , and the value of the hand
is sum of the values of the cards in hand. Determine the number of hands
having the value 2004.
Hint: Use generating functions.
Solution sketch: This is a bit harder problem than I expected (read: not
something I would expect on a final). There is no restriction of hand size,
so each card can be picked or not. Consider the generating function for the
possible values of the red cards:
1
2
3
10
(1 + x2 )(1 + x2 )(1 + x2 ) · · · (1 + x2 )
Here, each parenthesis corresponds to picking the card with number k or not.
If we pick card with number k, it contributes with value 2k , so that is what
we put in the exponent. A similar thing happens for a joker, we either take
it or not, giving (1 + x)2 since we have two jokers, each with value 20 = 1.
The total generating function is then
h
i3
21
22
23
210
(1 + x )(1 + x )(1 + x ) · · · (1 + x ) (1 + x)2 .
You should be able to get this far.
To find the coefficient of x2004 is messy, but doable. We first need to
simplify the product
1
2
3
10
(1 + x2 )(1 + x2 )(1 + x2 ) · · · (1 + x2 ).
Note that the exponents are powers of two, so the possible exponents in
the expansion of this are all numbers that can be written as a sum of
21 , 22 , . . . , 210 . Thinking about this for a moment — compare this with Example 3 on page 267 in Tucker — and using the fact that the binary expansion
of a number is unique, we get
1
2
3
10
(1 + x2 )(1 + x2 )(1 + x2 ) · · · (1 + x2 ) = 1 + x2 + x4 + x6 + x8 + · · · + x2046 .
2
It is now enough to find the coefficient of x2004 , x2003 and x2002 of
3
1 + x2 + x4 + x6 + x8 + · · · + x2046
(1)
in order to solve our problem. We note that the coefficient of x2003 in (1)
is 0, since all exponents inside are even. This is completely natural, every
colored card has an even value (a power of 2), so it cannot give an odd sum.
Thus, the solution is just the sum of the coefficients of x2004 (no jokers)
and x2002 (and two jokers) in (1). Notice that these coefficients are the same
as the corresponding coefficients in
3
1 + x2 + x4 + x6 + x8 + · · · + x2046 + · · ·
(2)
since the higher-order terms do not contribute anyway. Substituting x2 = t,
it is now the same as finding the coefficients of t1002 and t1001 in
1 + t + t1 + t3 + · · ·
3
=
1
(1 − t)3
(3)
and this we can do using p.257 in the book, identity (5). We get
1001 + 3 − 1
1002 + 3 − 1
1003
1004
+
=
+
1001
1002
1001
1002
1003 · 1002 1004 · 1003
+
=
2
2
= 1006009
Example 5. Mr. Svensson has 1 yellow, 4 green and 6 blue flags. He wants
to put n of them on a flag-pole, in a column. Flags with same color are
considered identical. Furthermore, Svensson wants the flags to be arranged
in alphabetical order (according to color name).
Find the generating function for the number of ways to put up flags according to Svenssons requirements, and compute the number of arrangements
with 5 flags.
Example 6. Find the generating function for the number of ways can you
tile a 2 × n-rectangle with tiles of the form
1. 1 × 2 and 2 × 1.
3
2. 1 × 2, 2 × 1 and 1 × 1.
Hint: You need to consider all possible “endings” of a 2 × n-rectangle.
Example 7. Solve
(
an+1
bn+1
= an + b n
= 2an − bn
with initial condition a0 = 1, b0 = 0.
Solution sketch: We let A(x) and B(x) be the corresponding g.f and
set up the system of equations:
(
P
A(x) − 1 = n≥1 an xn
P
B(x) − 0 = n≥1 bn xn
Using the recurrence, and simplifying, we get
(
A(x) − 1 = xA(x) + xB(x)
B(x) − 0 = 2xA(x) − xB(x)
The bottom equation gives that B(x) =
equation gives
A(x) − 1 = xA(x) +
2x2
A(x)
1+x
2x
A(x),
(1+x)
=⇒
which inserted in the first
(1 − 3x2 )A(x) = 1 + x.
This gives
2x
1+x
B(x) =
.
2
1 − 3x
1 − 3x2
Using partial fractions on these expressions, after some rather tedious work,
one get
√
√
(
1
1
(3+ 3)
(3− 3)
A(x) = 61−√3x + 61+√3x
A(x) =
B(x) =
√
1/ 3
√
1− 3x
4
−
√
1/ 3
√
1+ 3x
From here, one can find the closed-form formulas for the series:
√ √
√
√
1
1
an = (3 + 3)( 3)n + (3 − 3)(− 3)n
6
6
√ n
1 √ n
1
bn = √ ( 3) − √ (− 3)
3
3
2
Alternatively,
√ n once√we nsee that the denominators are 1 − 3x , we know that
an = A 3 + B(− 3) for some A, B, and likewise for bn . We can solve for
the A and B using the initial conditions, and use the recurrence for finding
that a1 = 1 and b1 = 2.
Remark: Finding the generating functions should be straightforward, but
it gets a bit tedious after that. Don’t worry if you did not solve it the first
time.
Example 8. Solve the following systems of linear equations, all with initial
condition a0 = 1, b0 = 1:
(
(
(
an+1 = an − 4bn
an+1 = 3an − bn + 1
an+1 = 2an − bn + 1
bn+1 = −3an + 2bn
bn+1 = 5an + 9bn
bn+1 = 2an + 5bn − 2
I suggest using generating functions. You should get integer roots for your
denominators in the generating functions. Remember that the generating
function for ck = 1 for all k ≥ 0 is (1 − x)−1 .
Example 9. An increasing binary tree on n vertices is a binary tree where
each vertex has a different label in {1, . . . , n} (each label appears exactly
once), and labels increase as we move down the tree. Each vertex has 0, 1 or
2 children (left and right). Let cn be the number of increasing binary trees
on n + 1 vertices.
1. Show that
cn+1 =
n X
n
k=0
k
ck cn−k .
2. Guess a closed form formula for cn and prove this formula.
Example 10. Let us consider n different objects, and r different boxes. How
many ways can you distribute the objects into these boxes such that
5
1. there is no extra restriction.
2. box i is empty.
3. no box is empty. (You end up with a summation formula).
The Stirling numbers (of the second kind) S(n, r) is the number of ways
to distribute n different objects into r non-empty sets. The order of the sets
does not matter. Use the answer from previous question to prove that
r
1X
r−k r
(−1)
kn.
S(n, r) =
r! k=0
k
Example 11. A permutation σ is an involution if σ 2 = id. For example
53241 is an involution, since if we apply this permutation twice, we get back
the identity permutation. Let dn be the number of involutions of size n,
where d0 = d1 = 1.
Explain the recursion dn = dn−1 + (n − 1)dn−2 .
Example 12. Find the generating function for the sequence an = n2 + 1.
Some problems we did in class
We did the examples in the book on integer partitions.
Example 13. A permutation of n is friendly there is at least one i such
that i and i + 1 appear next to each other in increasing order. How many
permutations of n are friendly?
What fraction of the permutations are friendly as n → ∞?
Example 14. We have 5 different boxes, and r objects, that we want to put
into the boxes, but at least one box is empty. In how many ways can we do
this?
Example 15. Solve the recursion an = 4an−1 − 8an−2 , a0 = 0 and a1 = 1.
Example 16. Find generating function for the sequence that satisfies an =
an−1 + n(n − 1) and a0 = 1.
6
Example 17. We have 25 pennies, 10 nickels, 3 cents, and 2 quarters. Find
the generating function for the number of ways to make n cents.
Example 18. You are going to an amusement park. There are four attractions, (haunted house, roller coaster, a carousel, water ride). You buy 25
tokens. Each attraction cost 3 tokens each ride, except the roller coaster
that costs 5. Obviously, you want to ride each ride at least once, but the
order of the rides does not matter. You do not have to use all tokens.
Find the generating function for the number of ways that you can you
spend your tokens.
Example 19. We make a flag, consisting of n vertical stripes. The flag
should start with some yellow stripes, some blue, and finally some red stripes.
We have 4 yellow stripes, 4 blue, and 4 red stripes. In addition, we have a
3-stripe wide yellow silk piece, and a 2-stripe wide blue piece. We cannot cut
these, but might use this piece instead of 3 ordinary yellow pieces, or 2 blue
pieces, respectively. We do not mix fabrics of the same color.
Find the generating function for the number of flags with n stripes.
Example 20. In some model, we have a0 = 1, a1 = c and an+2 = 29 an+1 −2an .
For what values of c is this sequence bounded?
Example 21. Tower of Hanoi: an = an−1 + 1 + an−1 = 2an−1 + 1 and a1 = 1.
Find a closed-form formula for an .
7
Download