Basic Combinatorics, Spring 2015 - University of Notre...

74
Basic Combinatorics, Spring 2015 Department of Mathematics, University of Notre Dame Instructor: David Galvin Abstract This document includes homeworks, quizzes and exams, and some supplementary notes from the Spring 2015 incarnation of Math 40210 — Basic Combinatorics, an undergraduate course offered by the Department of Mathematics at the University of Notre Dame. The notes have been written in a single pass, and as such may well contain typographical (and sometimes more substantial) errors. Comments and corrections will be happy received at [email protected]. Contents 1 General information about homework 3 2 Homework 1 (due January 23) 4 3 Homework 2 (due January 30) 12 4 Quiz 1 (February 4) 20 5 Quiz 1 Solutions 21 6 Homework 3 (due February 13) 22 7 Homework 3 Solutions 30 8 Homework 4 (due February 27) 34 9 Homework 4 Solutions 42 10 Quiz 2 (February 25) 46 11 Quiz 2 Solutions 47 12 Midsemester exam (March 4) 48 13 Homework 5 (due March 20) 54 14 Graph terminology 59 15 Homework 6 (due April 1) 61 1

Transcript of Basic Combinatorics, Spring 2015 - University of Notre...

Basic Combinatorics, Spring 2015

Department of Mathematics, University of Notre Dame

Instructor: David Galvin

Abstract

This document includes

• homeworks, quizzes and exams, and

• some supplementary notes

from the Spring 2015 incarnation of Math 40210 — Basic Combinatorics, an undergraduatecourse offered by the Department of Mathematics at the University of Notre Dame. The noteshave been written in a single pass, and as such may well contain typographical (and sometimesmore substantial) errors. Comments and corrections will be happy received at [email protected].

Contents

1 General information about homework 3

2 Homework 1 (due January 23) 4

3 Homework 2 (due January 30) 12

4 Quiz 1 (February 4) 20

5 Quiz 1 Solutions 21

6 Homework 3 (due February 13) 22

7 Homework 3 Solutions 30

8 Homework 4 (due February 27) 34

9 Homework 4 Solutions 42

10 Quiz 2 (February 25) 46

11 Quiz 2 Solutions 47

12 Midsemester exam (March 4) 48

13 Homework 5 (due March 20) 54

14 Graph terminology 59

15 Homework 6 (due April 1) 61

1

16 Quiz 3 (March 30) 66

17 Homework 7 (due April 20) 67

18 Homework 8 (due April 29) 71

2

1 General information about homework

In general homework will be assigned on a Friday, and will be due in class the following Friday. Asthey are assigned, homework problems will be added to this document, and will be posted on thewebsite. At the same time I will make an email announcement.

I will distribute a printout of the homework problems in class each week, with plenty of blankspace. The solutions that you submit should be presented on this printout (using the flip side ofa page if necessary). You may also print out the relevant pages from the website; if you do so, youmust staple your pages together. I reserve the right to

• not grade any homework that is not presented on the printout, and

• deduct points for homework that is not stapled.

The weekly homework is an important part of the course; it gives you a chance to think moredeeply about the material, and to go from seeing (in lectures) to doing. It’s also your opportunityto show me that you are engaging with the course topics.

Homework is an essential part of your learning in this course, so please take it very seriously. Itis extremely important that you keep up with the homework, as if you do not, you may quickly fallbehind in class and find yourself at a disadvantage during exams.

You should treat the homework as a learning opportunity, rather than something you need toget out of the way. Reread, revise, and polish your solutions until they are correct, concise, efficient,and elegant. This will really deepen your understanding of the material. I encourage you to talkwith your colleagues about homework problems, but your final write-up must be your own work.

Homework solutions should be complete (and in particular presented in complete sentences),with all significant steps justified. I reserves the right to

• not grade any homework that is disorganized and incoherent.

3

2 Homework 1 (due January 23) Name:

The purpose of this homework is to get used to using the pigeon-hole principle and the method ofinduction.

Reading: Chapters 1 and 2 of the textbook.

1. 17 points are placed in an equilateral triangle of side length 1. Prove that two of the pointsare within distance 1/4 of each other.

4

2. (a) Select n + 1 distinct whole numbers between 1 and 2n. Prove that two of the numbersare coprime. (Numbers a and b are coprime if the greatest common divisor of a and b is1.)

(b) Is the conclusion still true if instead n numbers are selected?

5

3. For each n, exhibit a sequence of n2 real numbers that has neither a monotone increasingsubsequence of length n + 1, nor a monotone decreasing subsequence of length n + 1 (thisshows the the bound in the Erdos-Szekeres theorem that we saw in class is tight).

6

4. Select 10 distinct two digit numbers. Prove that is is possible to select disjoint subsets A,B of the set of chosen numbers, so that the sum of the elements of A equals the sum of theelements of B.

7

5. Prove (by induction on n) that for all n ≥ 1,

1 +1√2

+1√3

+ . . .+1√n≤ 2√n.

(One can also prove by induction that the sum is at least 2(√n+ 1 − 1), and so get a very

good estimate for∑n

i=1 i−1/2.)

8

6. The sum of the first n perfect kth powers turns out to be a polynomial in n of degree k + 1.For example,

1 + 2 + 3 + . . .+ n =n(n+ 1)

2

12 + 22 + 32 + . . .+ n2 =n(n+ 1)(2n+ 1)

6

13 + 23 + 33 + . . .+ n3 =

(n(n+ 1)

2

)2

.

Proof the second of these identities (12 + 22 + 32 + . . .+ n2 = . . .) by induction on n.

9

7. You are given a 64 by 64 chessboard, and 1365 L-shaped tiles (2 by 2 tiles with one squareremoved). One of the squares of the chessboard is painted purple. Is it possible to tile thechessboard using the given tiles, leaving only the purple square exposed?

10

8. In class we defined the number U(n) to be the number of different ways that people canbe seated in a row of n adjacent chairs in an “unfriendly” way: no two adjacent chairs areoccupied. We gave the following recursive specification of U(n): U(1) = 2, U(2) = 3 andU(n) = U(n−1)+U(n−2) for n ≥ 3, and we proved by induction that U(n) ≤ 1.25φn, whereφ = (1 +

√5)/2. Given an inductive proof of the following near-matching lower bound: there

is a constant C > 0 (as part of your solution, you should figure out an explicit value for C)such that for all n ≥ 1, U(n) ≥ Cφn.

11

3 Homework 2 (due January 30) Name:

The purpose of this homework is to become comfortable with the six basic counting problemsintroduced in lectures.

Reading: Chapter 3 of the textbook.

1. (a) How many subsets does [n] have, that contain none of the elements 1, 2? (The notation“[n]” is shorthand for “{1, 2, 3, . . . , n}”.)

(b) How many subsets does [n] have, that contain at least one of the elements 1, 2?

(c) How many subsets does [n] have, that contain both of the elements 1, 2?

12

2. In how many ways can the elements of [n] be permuted (arranged in order), in such a waythat 1 is listed later than both 2 and 3?

13

3. Let n = pa11 pa22 . . . pakk be the prime factorization of n (so each of the pi’s are distinct prime

numbers, p1 < p2 < . . . < pk, and each ai is a positive (non-zero) whole number). How manypositive factors (including 1 and n) does n have?

14

4. Andy and Barbara play a game: they roll four dice. If at least one of the dice comes up six,Andy wins the game, and otherwise Barbara does.

(a) In how many different ways can the game proceed (assuming the dice are distinguishablefrom each other)?

(b) In how many of these ways does Andy win?

(c) In how many of these ways does Barbara win?

15

5. In how many different ways can n rooks be placed on an n-by-n chessboard, with no two rooksattacking each other? (Two rooks attack each other if they are either in the same row as eachother, or the same column).

16

6. My class has n sophomores, n juniors and n seniors. In how many ways can the class breakup into n triples, with each triple including one sophomore, one junior and one senior? (Theorder of people within each group doesn’t matter, nor does the order in which the groups arecreated.)

17

7. I invite n couples to a party. I want to ask some subset (perhaps empty) of the 2n attendeesto give a speech, but I don’t want to ask both members of any couple. In how many ways canI do this? [Your answer might be quite simple, or it might be a slightly less simple sum ofbinomial coefficients.]

18

8. For all n ≥ 1, the number of even-sized subsets of {1, . . . , n} is equal to the number of odd-sized subsets of {1, . . . , n}. Proof this bijectively. Meaning: let En be the set of even-sizedsubsets of {1, . . . , n}, and let On be the set of odd-sized subsets of {1, . . . , n}. Give a bijectionf : En → On. Don’t forget to prove that the function you give is both injective and surjective.

19

4 Quiz 1 (February 4) Name:

1. How many different anagrams does the word MISSISSIPPI have? (The four S’s are indistinguishablefrom one another, as are the four I’s and two P’s.)

2. Give a combinatorial proof of the binomial coefficient identity

k

(n

k

)= n

(n− 1

k − 1

),

by describing a counting problem whose answer is both the left- and right-hand side of the aboveequality, depending on how you count. Clearly describe both ways of counting.

20

5 Quiz 1 Solutions

1. How many different anagrams does the word MISSISSIPPI have? (The four S’s are indistinguishablefrom one another, as are the four I’s and two P’s.)

Solution: 11!4!4!2! .

2. Give a combinatorial proof of the binomial coefficient identity

k

(n

k

)= n

(n− 1

k − 1

),

by describing a counting problem whose answer is both the left- and right-hand side of the aboveequality, depending on how you count. Clearly describe both ways of counting.

Solution: We count the number of committees-of-size-k-with-chair that can be selected from n people.One way to make the selection is to first choose the committee of size k (

(nk

)ways), then from among

the members of the committee select the chair (k ways), leading to a count of k(nk

). Another way

to make the selection is to first choose the chair (n ways), then from the remaining n − 1 choose theremaining k − 1 members of the committee (

(n−1k−1

)ways), leading to a count of n

(n−1k−1

).

21

6 Homework 3 (due February 13) Name:

The purpose of this homework is to explore the binomial theorem, and some distribution problems.

Reading: Sections 4.1, 4.2, 5.1 and 5.2 of the textbook.

1. Prove that for all n ≥ 0,n∑

k=0

(n

k

)2

=

(2n

n

).

22

2. Fix n ≥ 2. Using induction on k, show that for 0 ≤ k ≤ n,

k∑i=0

(−1)i(n

i

)= (−1)k

(n− 1

k

).

(Note that the right-hand side is the alternating sum of the terms on row k of Pascal’s triangle,up to

(nk

). Plugging in k = n gives the identity

∑ni=0(−1)

(ni

)= 0).

23

3. Prove that for all n > 1, we have

n∑k=0

(−1)k+1

k + 1

(n

k

)=−1

n+ 1.

[Hint: look at our analytic proof of the committee-chair identity from class].

24

4. Among all the compositions of 15, how many do not have 1 as the first part? [Justify youranswer!]

25

5. How many compositions of n have an even number of parts? [Justify your answer!]

26

6. Let F (n) denote the number of partitions of the set [n] with no blocks of size one. Prove that

B(n) = F (n) + F (n+ 1).

Ideally, your solution should involve a bijection.

27

7. Prove that the following identity involving the Stirling numbers of the second kind is correct:Let f(x) = ee

x. For n ≥ 0,

dn

dxnf(x) = f(x)

∑k≥0

S(n, k)ekx.

[Hint: induction on [n]. Use the Stirling recurrence!]

28

8. Prove that for n ≥ 3,

S(n, 3) =1

6(3n − 3 · 2n + 3) .

(The formula works also for n = 1 and 2, but it’s easier to think about it when n ≥ 3.)

29

7 Homework 3 Solutions

1. Prove that for all n ≥ 0,n∑

k=0

(n

k

)2

=

(2n

n

).

Solution: Consider a group of 2n people, n women and n men. RHS counts number of waysof selecting n people from among the 2n, without regard to gender split. LHS counts samething, by first deciding how many (k) women are selected (k = 0, . . . , n), then selecting the kwomen (

(nk

)choices), then deciding who are the k men not selected (

(nk

)choices), leaving the

remaining n− k men to go together with the k women to make n selected in all.

2. Fix n ≥ 2. Using induction on k, show that for 0 ≤ k ≤ n,

k∑i=0

(−1)i(n

i

)= (−1)k

(n− 1

k

).

Solution: Base case k = 0: assertion is that (−1)0(n0

)= (−1)0

(n−10

), which reduces to 1 = 1

so is true.

Induction step: assume the statement is true for some 0 ≤ k ≤ n− 1. Then

k+1∑i=0

(−1)i(n

i

)= (−1)k+1

(n

k + 1

)+

k∑i=0

(−1)i(n

i

)= (−1)k+1

(n

k + 1

)+ (−1)k

(n− 1

k

)(induction

= (−1)k+1

((n

k + 1

)−(n− 1

k

))= (−1)k+1

(n− 1

k + 1

)(Pascal),

so the statement is true for k + 1. This completes the induction.

3. Prove that for all n > 1, we have

n∑k=0

(−1)k+1

k + 1

(n

k

)=−1

n+ 1.

Solution: Let f(x) = (1 + x)n and g(x) =∑n

k=0

(nk

)xk. By the binomial theorem, f(x) =

g(x). An antiderivative of f(x) is F (x) = (1+x)n+1

n+1 , and an antiderivative of g(x) is G(x) =∑nk=0

(nk

)xk+1

k+1 . From calculus we know that there is a constant C such that

F (x) = G(x) + C.

Evaluating both sides at x = 0, get 1/(n+ 1) = C. Evaluating both sides at x = −1, get

0 =

n∑k=0

(−1)k+1

k + 1

(n

k

)+

1

n+ 1,

as required.

30

4. Among all the compositions of 15, how many do not have 1 as the first part? [Justify youranswer!]

Solution: Compositions of 16 that have 1 as their first part are in bijective correspondencewith compositions of 14 (the correspondence is obtained by simply deleting the 1 at thebeginning of the composition). From class we know that 14 has 213 compositions, an 15 has214 compositions. So the number of compositions of 15 that do not have 1 as the first part is214 − 213 = 213.

5. How many compositions of n have an even number of parts? [Justify your answer!]

Solution: We know from class that n has(n−1k−1)

compositions with exactly k parts, so thenumber of compositions with an even number of parts is(

n− 1

2− 1

)+

(n− 1

4− 1

)+

(n− 1

6− 1

)+ . . . =

(n− 1

1

)+

(n− 1

3

)+

(n− 1

5

)+ . . . .

Now from class we know that(n− 1

1

)+

(n− 1

3

)+

(n− 1

5

)+ . . . =

(n− 1

0

)+

(n− 1

2

)+

(n− 1

4

)+ . . .

and (n− 1

1

)+

(n− 1

2

)+

(n− 1

3

)+ . . . = 2n−1

so (n− 1

1

)+

(n− 1

3

)+

(n− 1

5

)+ . . . =

1

22n−1 = 2n−2,

so the number of compositions of n with an even number of parts is 2n−2.

6. Let F (n) denote the number of partitions of the set [n] with no blocks of size one. Prove that

B(n) = F (n) + F (n+ 1).

Ideally, your solution should involve a bijection.

Solution: Let Bn be the set of partitions of [n] into non-empty blocks, Fn the set of partitionsof [n] into non-empty blocks, none of which have size 1, and Fn+1 the set of partitions of [n+1]into non-empty blocks, none of which have size 1. We want

|Bn| = |Fn|+ |Fn+1|

(note that Fn and Fn+1 are disjoint).

Notice that Fn ⊆ Bn. Let B′n = Bn \ Fn. Since

|B′n| = |Bn| − |Fn|,

we will be done if we show |B′n| = |Fn+1|. We’ll do this via a bijection.

Given an element of p of B′n, take all the blocks of size 1 in p (there must be at least 1),take their union, and add element n + 1. Together with the remaining blocks of p, we get apartition of [n+1] with no blocks of size 1, so an element of Fn+1. The map we have describedis injective: if p 6= p′, then either p and p′ have different singleton blocks, in which case theimages of p and p′ can be told apart by the block containing n + 1, or they have different

31

non-singleton blocks, in which case the images can be told apart by the blocks not containingn+ 1. It is also surjective: if q is an element of Fn+1, then in q n+ 1 is in a block with someother numbers. Remove n+ 1 from this block, and split up what is left into singleton blocks.The resulting partition p is in B′n, and its image is q. So the map is a bijection and we aredone.

7. Prove that the following identity involving the Stirling numbers of the second kind is correct:Let f(x) = ee

x. For n ≥ 0,

dn

dxnf(x) = f(x)

∑k≥0

S(n, k)ekx.

Solution: We proceed by induction on n.

Base case n = 0: the assertion is that f(x), the zeroth derivative of f(x) is equal tof(x)S(0, 0)e0x, which is true.

Induction step: Assume the statement is true for some n ≥ 0. Then

dn+1

dxn+1f(x) =

d

dx

(dn

dxnf(x)

)

=d

dx

f(x)∑k≥0

S(n, k)ekx

(induction)

= f(x)∑k≥0

kS(n, k)ekx + f ′(x)∑k≥0

S(n, k)ekx

= f(x)∑k≥1

kS(n, k)ekx + f(x)∑k≥1

S(n, k − 1)ekx

= f(x)∑k≥1

(S(n, k − 1) + kS(n, k)) ekx

= f(x)∑k≥1

S(n+ 1, k)4kx

= f(x)∑k≥0

S(n+ 1, k)4kx,

as required, completing the induction. At various points here we have done re-indexing, usedthe recurrence relation for the Stirling numbers of the second kind, and used that S(n, 0) = 0(to contract/expand summations).

8. Prove that for n ≥ 3,

S(n, 3) =1

6(3n − 3 · 2n + 3) .

Solution: We proceed by induction on n.

Base case n = 3: the assertion is that S(3, 3) = (1/6)(33 − 2 · 23 + 3), which is true since itreduces to S(3, 3) = 1.

Induction step: Assume the statement is true for some n ≥ 3. Then

S(n+ 1, 3) = S(n, 2) + 3S(n, 3)

=1

2(2n − 2) +

3

6(3n − 3 · 2n + 3) .

32

In the first line we used the recurrence relation for the Stirling numbers of the second kind,and in the second line we used induction and the formula we already know for the numberS(n, 2). After a little algebra, what we have reduces to

S(n, 3) =1

6

(3n+1 − 3 · 2n+1 + 3

),

completing the induction.

33

8 Homework 4 (due February 27) Name:

The purpose of this homework is to explore cycles in permutations, inclusion-exclusion, and gener-ating functions.

Reading: Section 6.1, Chapter 7 and Section 8.1 of the textbook.

1. A permutation f : [n]→ [n] is called an involution if f2 (f composed with itself) is the identitypermutation that sends everything to itself.

• part a) For each of n = 1, . . . , 5, count how many permutations of [n] are involutions.

34

• part b) Find a formula for In, the number of permutations of [n] that are involutions(your answer may involve a summation).

35

2. Find a formula for the number of permutations of [2n] whose longest cycle has length n+ 1.Your formula should not involve a summation.

36

3. Let D(n) be the number of derangements of [n], that is, the number of permutations in whichno element is returned to its original position. Set D(0) = 1 (and note that D(1) = 0). Provethat for all n ≥ 1,

D(n+ 1) = n(D(n) +D(n− 1)).

You may use the formula we derived in class for D(n); bonus point for a combinatorial proof.

37

4. Prove that for each n ≥ 1,

n! =n∑

i=0

(n

i

)D(i)

(here D(n) is the number of derangements of [n]; recall from the last question that D(0) = 1).[Hint: A combinatorial proof is easiest here.]

38

5. Let Fk(n) denote the number of partitions of [n] into exactly k non-empty blocks, none ofwhich has size 1. Find a formula for Fk(n) in terms of Stirling numbers of the second kind.(Your formula may involve a summation).

39

6. A sequence is defined recursively by a0 = 1, a1 = 4 and an = 4an−1 − 4an−2 for n ≥ 2.

• part a) Use the method of “use recurrence where possible, use initial conditions wherenot” to find a closed-form for the generating function of the ai’s.

40

• part b) Using the result of the previous part, find an explicit formula for an for eachn ≥ 0. (It might be helpful to write down the geometric series formula and differentiateit).

41

9 Homework 4 Solutions

1. A permutation f : [n]→ [n] is called an involution if f2 (f composed with itself) is the identitypermutation that sends everything to itself.

• part a) For each of n = 1, . . . , 5, count how many permutations of [n] are involutions.

Solution:

– n = 1: 1.

– n = 2: 2.

– n = 3: with no 2-cycle: (1)(2)(3). With 1 2-cycle: (1)(23), (12)(3), (13)(2). So 4 inall.

– n = 4: with no 2-cycle: 1. With 1 2-cycle:(42

). With 2 2-cycles: 3. So 10 in all.

– n = 5: with no 2-cycle: 1. With 1 2-cycle:(52

). With 2 2-cycles: 5× 3. So 26 in all.

• part b) Find a formula for In, the number of permutations of [n] that are involutions(your answer may involve a summation).

Solution: To be an involution, a permutation must have cycles of length 1 and 2 only,so it must have cycle type (n− 2k, k) for some 0 ≤ k ≤ [n/2]. From a formula derived inclass, the number of permutations of [n] with cycle type (n− 2k, k) is

n!

(n− 2k)!k!1n−2k2k=

n!

(n− 2k)!k!2k,

and so

In =

[n/2]∑k=0

n!

(n− 2k)!k!2k.

2. Find a formula for the number of permutations of [2n] whose longest cycle has length n+ 1.

Solution: There can be only one cycle of length n + 1. There are(

2nn+1

)ways to choose the

n+ 1 elements of this cycle, and n! ways to cyclicly arrange them. There are n− 1 remainingelements, which can be arbitrarily permuted (in (n−1)! ways). So the number of permutationsis (

2n

n+ 1

)n!(n− 1)!.

3. Let D(n) be the number of derangements of [n], that is, the number of permutations in whichno element is returned to its original position. Set D(0) = 1 (and note that D(1) = 0). Provethat for all n ≥ 1,

D(n+ 1) = n(D(n) +D(n− 1)).

You may use the formula we derived in class for D(n); bonus point for a combinatorial proof.

42

Solution: Using the formula D(n) =∑n

k=0(−1)k n!k! , we have

n(D(n) +D(n− 1)) = n

n∑k=0

(−1)kn!

k!+ n

n−1∑k=0

(−1)k(n− 1)!

k!

=n−1∑k=0

(−1)k(n+ 1)!

k!+ n(−1)n

n!

n!

=n∑

k=0

(−1)k(n+ 1)!

k!

= D(n+ 1).

Here’s a combinatorial proof: Let Dn+1 be the set of derangements of [n+1]. For i = 1, . . . , n,let Di

n+1 be the set of those elements of Dn+1 in which n+ 1 is sent to i. Note that the Din+1

are disjoint and cover Dn+1, so

D(n+ 1) =n∑

i=1

|Din+1|.

We will show that for each i, |Din+1| = D(n) +D(n− 1), which will be enough to obtain the

claimed identity. To de-clutter the notation, we consider only the case i = n; all other casesproceed similarly.

Partition Dnn+1 as T n

n+1∪N nn+1, where T n

n+1 is the set of those derangements in Dnn+1 in which

n is mapped to n + 1. In the presence of this n + 1 ↔ n transposition, it is evident that|T n

n+1| = D(n − 1) (there is a clear bijective correspondence from derangements of [n − 1] toelements of T n

n+1).

An f ∈ N nn+1 maps n + 1 to n, and there is some j ∈ [n − 1] that maps to n + 1. Consider

f ′ : [n] → [n] that agrees with f on [n] \ j, and sends j to n. This is readily seen tobe a derangement of [n]; moreover, the map f → f ′ is a bijection from N n

n+1 to Dn, so|N i

n+1| = D(n).

This completes the proof of the identity.

4. Prove that for each n ≥ 1,

n! =n∑

i=0

(n

i

)D(i)

(here D(n) is the number of derangements of [n]; recall from the last question that D(0) = 1).[Hint: A combinatorial proof is easiest here.]

Solution: The left-hand side counts the number of permutations of n directly. The right-hand side counts the sam thing by first deciding i, the number of non-fixed points of thepermutation (0 ≤ i ≤ n), then selecting the non-fixed points (

(ni

)ways), and then deranging

these points among themselves (D(i) ways). This completely determines the permutation, asall the fixed points get sent to themselves.

5. Let Fk(n) denote the number of partitions of [n] into exactly k non-empty blocks, none ofwhich has size 1. Find a formula for Fk(n) in terms of Stirling numbers of the second kind.(Your formula may involve a summation).

43

Solution: Let Ai be the set of partitions of [n] into exactly k non-empty blocks in whichelement i is in a block of size 1. We seek | ∪ni=1 Ai| — this is the number of partitions with atleast one block of size 1, so the number with no blocks of size 1 is S(n, k) minus this number.By inclusion-exclusion,

| ∪ni=1 Ai| = |A1|+ |A2|+ . . .− |A1 ∩A2| − . . .+ |A1 ∩A2 ∩A3|+ . . . .

Now since, for example, a partition in |A1 ∩A2 ∩A3| fixes each of 1,2,3 in singleton blocks, itmust partition the remaining n− 3 elements into k − 3 non-empty blocks, so

|A1 ∩A2 ∩A3| = S(n− 3, k − 3),

and more generally, the intersection of any ` of the Ai’s has size S(n− `, k− `). It follows that

| ∪ni=1 Ai| = nS(n− 3, k − 3)−(n

2

)S(n− 2, k − 2) +

(n

3

)S(n− 3, k − 3)− . . . ,

and so

Fk(n) = n!− nS(n− 3, k − 3) +

(n

2

)S(n− 2, k − 2)−

(n

3

)S(n− 3, k − 3) + . . .

=

n∑`=0

(−1)`(n

`

)S(n− `, k − `).

6. A sequence is defined recursively by a0 = 1, a1 = 4 and an = 4an−1 − 4an−2 for n ≥ 2.

• part a) Use the method of “use recurrence where possible, use initial conditions wherenot” to find a closed-form for the generating function of the ai’s.

Solution: We begin by forming the generating function A(x) of (an)n≥0:

A(x) = a0 + a1x+ a2x2 + a3x

3 + . . .

= 1 + 4x+ (4a1 − 4a0)x2 + (4a2 − 4a1)x

3 + . . .

= 1 + 4x+ 4x(a1x+ a2x2 + . . .)− 4x2(a0 + a1x+ . . .)

= 1 + 4x+ 4x(A(x)− 1)− 4x2A(x),

so

A(x) =1

1− 4x+ 4x2

=1

(1− 2x)2

• part b) Using the result of the previous part, find an explicit formula for an for eachn ≥ 0. (It might be helpful to write down the geometric series formula and differentiateit).

Solution: Since

1

1− z= 1 + z + z2 + z3 + . . .+ zn + zn+1 + . . . ,

differentiating both sides we get

1

(1− z)2= 1 + 2z + 3z2 + . . .+ nzn−1 + (n+ 1)zn + . . . ,

44

and so

1

(1− 2x)2= 1 + 2(2x) + 3(2x)2 + . . .+ n(2x)n−1 + (n+ 1)(2x)n + . . . ,

so an = (n+ 1)2n.

45

10 Quiz 2 (February 25) Name:

1. How many positive integers, not larger than 10,000, are neither perfect squares nor perfect cubes?

2. Write down a formula that expresses the Stirling number of the second kind S(n, k) in terms of “earlier”Stirling numbers (numbers of the form S(n− 1, j)). Explain why the formula is correct.

46

11 Quiz 2 Solutions

1. How many positive integers, not larger than 10,000, are neither perfect squares nor perfect cubes?

Solution: Let A2 be the number of numbers not larger than 10,000 that are perfect squares. Since10000 = 1002, |A2| = 100. Let A3 be the number of numbers not not larger than 10,000 that are perfectcubes. Since 10000 = 21.54 . . .3, |A3| = 21. Since A2 ∩ A3 is the number of numbers not larger than10,000 that are perfect sixth powers, and since 10000 = 4.6 . . .6, |A2 ∩A3| = 4. By inclusion-exclusion,

|A2 ∩A3| = 100 + 21− 4 = 117,

so there are 117 numbers not larger than 10,000 that are either perfect squares or perfect cubes, and10000− 117 = 9883 numbers not larger than 10,000 that are neither perfect squares nor perfect cubes.

2. Write down a formula that expresses the Stirling number of the second kind S(n, k) in terms of “earlier”Stirling numbers (numbers of the form S(n− 1, j)). Explain why the formula is correct.

Solution:S(n, k) = S(n− 1, k − 1) + kS(n− 1, k).

The S(n − 1, k − 1) counts partitions of [n] into k non-empty blocks in which element n is in a blockon its own (so the remaining n− 1 elements have to be partitioned into k − 1 non-empty blocks), andthe kS(n − 1, k) counts partitions of [n] into k non-empty blocks in which element n is in a block ofsize larger than 1 (so the remaining n − 1 elements have to be partitioned into k non-empty blocks,and element n has to go into one of these k blocks).

47

12 Midsemester exam (March 4) Name:

This exam is for Math 40210, Spring 2015.This exam contains 5 problems on 6 pages (including the front cover).

This is an open-book exam. You may use the textbook, old homeworks, notes, etc.You may use a calculator.

For full credit show all your work on the paper provided.

Scores

Question Score Out of

1 10

2 10

3 10

4 10

5 10

Total 50

MAY THE ODDS BE EVER IN YOUR FAVOR!

48

1. (a) Calculate(105

). (I want an explicit decimal number.)

(b) Prove the following identity involving binomial coefficients: for fixed n ≥ 0,

n∑k=0

(k + 100

k

)=

(n+ 101

n

).

(A proof by induction on n is fine here; bonus points for a combinatorial proof).

49

2. (a) Which is greater: A: the number of ways of splitting a class of 12 students into fourgroups of size 3, or B: the number of ways of splitting a class of 12 students into threegroups of size 4? [In both cases, the order of the people within each group does notmatter, and the order of the groups does not matter.]

(b) What if the order in which the groups are created does matter (but again the order ofthe people within each group does not matter)?.

50

3. (a) State the inclusion-exclusion formula for calculating |A ∪B ∪ C ∪D|.

(b) How many numbers between 1 and 2100 are divisible by at least one of 3, 5 or 7?

51

4. A sequence a0, a1, a2, . . . is given by the recurrence relation:

a0 = 0, a1 = 3, an = an−1 + 2an−2 for n ≥ 2.

(a) Use the recurrence to calculate a2, a3, a4, a5 and a6.

(b) Based on the values you have computed, guess what is the formula for generating an forgeneral n, and use induction to prove that the formula is correct.

52

5. (a) How many ways are there to partition a set of size n into n− 1 non-empty blocks?

(b) Prove that the Stirling numbers of the second kind S(n, k) satisfy the following recur-rence:

S(n+ 1, k) =

n∑j=0

(n

j

)S(n− j, k − 1).

Hint: What size is the block that n+ 1 belongs to?

53

13 Homework 5 (due March 20) Name:

The purpose of this homework is to explore Catalan numbers, products of generating functions, andthe generalized Binomial theorem.

Reading: Sections 4.3 and 8.1.2 of the textbook.

1. Let Sn be the number of sequences of integers (a1, . . . , an) with 1 ≤ a1 ≤ a2 ≤ . . . ≤ an,and with ai ≤ i for each i = 1, . . . , n. So, for example, S3 = 5 with the five sequences being111, 112, 113, 122, 123. By convention, S0 = 1. Show that Sn is the nth Catalan number.Hint: look at the last i for which ai = i.

54

2. A triangulation of a convex n-gon is a collection of diagonals, that don’t intersect exceptpossibly at their endpoints, that breaks the n-gon up into triangles. So, there’s only oneway to triangulate a 3-gon (triangle) since it is already triangulated; there are two waysto triangulate a 4-gon (quadrilateral) ABCD (either join A to C or B to D), and there arefive ways to triangulate a 5-gon (pentagon); see http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2002/AjitRajwade/#Catalan for pictures of these five ways, as well as of the 14ways to triangulate a 6-gon (hexagon) and the 42 ways to triangulate a 7-gon (heptagon).

Let Tn be the number of ways to triangulate an (n + 2)-gon (by convention, T0 = 1). Showthat for n ≥ 1,

Tn = T0Tn−1 + T1Tn−2 + . . .+ Tn−1T0,

so that Tn is the nth Catalan number.

55

3. In an election between two candidates N and M , N gets n votes and M gets m votes, m ≥ n.In how many ways can the n+m votes be ordered, so that if the votes were counted in thatorder, M would never trail N in the count? (If m = n, the answer is the same as the numberof ways that the Cubs and White Sox can play to an n-n tie with the Cubs never trailing, sois the nth Catalan number. Hint: Generalize the reflection principle we saw in class to provethe Catalan number formula. Don’t forget the reality check: if your answer doesn’t reduce to(2nn

)/(n+ 1) when m = n, something is wrong).

56

4. Use the generalized Binomial theorem we saw in class to verify that for each k ≥ 0,

1

(1− x)k+1=∑n≥0

(n+ k

k

)xn.

57

5. Let (a0, a1, a2, . . .) be an arbitrary sequence, with generating function A(x) (=∑

n≥0 anxn).

• part a): Let (c0, c1, c2, . . .) be the convolution of (a0, a1, a2, . . .) with the sequence (1, 1, 1, . . .)(all 1’s). Express cn in terms of the ai’s.

• part b): What is the generating function of the sequence (a0, a0+a1, a0+a1+a2, . . . ,∑n

k=0 ak, . . .)?[Your answer should be in terms of A(x)].

58

14 Basic terminology of graphs

A graph is a set V of vertices, together with a set E of edges. Each edge consists of anunordered pair of vertices. We usually visualize a graph by drawing a dot for each vertex, anddrawing an arc (or curve) between two vertices exactly when those two vertices form an edge. Theprecise location of the dots, and the precise way in which we draw the curves representing edges, isnot important; all that matters in a graph is the list of vertices and edges.

NB: The singular of “vertices” is “vertex”. One vertex, two vertices (red vertex, blue vertex...).

There are many types of graph. For example,

• a general graph or mutligraph (see b) above) allows the same pair of vertices to appeartogether in an edge multiple times (e.g., e4 and e5 in b)), and also allows loops: edgesconsisting of the same vertex twice (e.g., e6 in b));

• a simple graph or just graph (see a) above) does not allow multiedges or loops;

• a directed graph (not shown) may have some edges that consist of ordered pairs of vertices,indicating direction; in a visual representation these edges would be indicated with an arrow.We won’t consider directed graphs.

If an edge (which we’ll usually denote something like e) is formed by two vertices, say u and v,then we’ll write this as e = uv, and we say:

• u and v are joined by e;

• edge e goes from u to v (and v to U);

• u and v are adjacent;

• u and v are neighbors;

• u and v are the endvertices of e.

59

The set of vertices that are adjacent to a vertex v is called the neighborhood of v. The degreeof a vertex v, denoted d(v), is the number of different ways that one can leave v along an arc in arepresentation of the graph. Notice that this means that any edge e = uv contributes one to thedegree, unless u = v (so the edge is a loop), in which case it contributes two. For example, in b)above, d(A) = 2, d(B) = d(C) = 3, and d(D) = 4 (and it would be 6 if there was a second loop atD). If G is simple, the degree of a vertex is just the size of the neighborhood; so, for example, in a)above, d(D) = 2.

There are many different notions of moving around a graph; here are a few that we will use. Wewill illustrate each with examples from a) above.

• A walk is a sequence u1u2 . . . un of vertices such that u1u2 is an edge, and u2u3, etc.. Repeti-tion of vertices and edges, and back-tracking, is allowed in a walk. Example: ABACDBC. Aclosed walk is one that ends at the same vertex that it began at. Example: ABACDBCA.A closed walk is sometimes called a circuit.

• A trail is a sequence u1u2 . . . un of vertices such that u1u2 is an edge, and u2u3, etc.. Repetitionof vertices is allowed, but not of edges, and in particular back-tracking is not allowed in a trail.Example: BACBD. A closed trail is one that ends at the same vertex that it began at.Example: BACB. An Eulerian trail is one that includes each each of the graph exactlyonce. Example: BACDBC. A closed Eulerian trail is one that includes each each of thegraph exactly once, ends at the same vertex that it began at. Picture a) has no example; butif there was a second edge from B to C, then BACDBCB would be an example.

• A path is a sequence u1u2 . . . un of vertices such that u1u2 is an edge, and u2u3, etc.. Rep-etition of vertices is not allowed (and so neither is backtracking or any kind of repetition ofedges). Also, this says that un must be different from u1. So another way of saying a pathis: it is a sequence u1u2 . . . un of distinct vertices such that u1u2 is an edge, and u2u3, etc.Example: BDC. A Hamiltonian path is one that includes all vertices (necessarily eachonce). Example: ABCD.

• A cycle is a sequence u1u2 . . . un of vertices such that u1u2 is an edge, and u2u3, etc., and alsounu1 is an edge. Repetition of vertices is not allowed (and so neither is backtracking or anykind of repetition of edges). Another way of saying a cycle is: it is a sequence u1u2 . . . un ofdistinct vertices such that u1u2 is an edge, and u2u3, etc., and unu1. Example: BDC. (Noticethat this was also an example of a path; when we call it a path, we are not including the finaledge CB; when we call it a cycle, we are). A Hamiltonian cycle is one that includes allvertices (necessarily each once). Example: ACBD.

A graph is said to be connected if between any two distinct vertices, there is a path. Forexample, both the graphs in a) and b) above are connected; but the multigraph consisting of theeight vertices A,B,C,D, A, B, C, D above, with edges as shown, would not be connected, as thereis no path, say, from A to D. A set of vertices with the property that between any two of themthere is a path, but there is no path from any of them to any other vertex of the grap, is called acomponent. A connected graph has one component (consisting of all the vertices); if a graph isnot connected, and so has multiple components, we say that is is disconnected. For example, if weremoved edges e1 and e4 from the graph a) above, it would become disconnected, with componentsA and B,C,D.

60

15 Homework 6 (due April 1) Name:

The purpose of this homework is to explore basics of graphs, including Eulerian trails and Hamil-tonian paths/cycles.

Reading: Chapter 9 through Section 9.2.

1. • Part a): Prove that in any simple graph, there are two vertices that have the same degreeas each other.

• part b): Give an example of a multigraph in which there are not two vertices with thesame degree.

61

2. • Part a): How many different simple (undirected, no multiple edges, no loops) graphs arethere on vertex set [n]? (Remember that [n] = {1, . . . , n}.) Your answer should notinvolve a summation.

• Part b): How many different directed graphs are there on vertex set [n], if we do notallow multiple edges, but do allow loops (at most one loop per vertex)? Clarification:“no multiple edges” in this context means that we cannot have more than one copy ofthe edge from a to b; but it is ok to have the edge from a to b (once) and the edge fromb to a (once). Your answer should not involve a summation.

• Part c): A tournament T on vertex set [n] is a directed graph on [n] such that for eachpair of distinct elements a, b ∈ [n], EITHER the edge from a to b is in T , OR the edgefrom b to a, BUT NOT BOTH. (Think of a tournament as encoding the results of around-robin tournament involving n teams, in which ties are not allowed). How manydifferent tournaments are there on vertex set [n]? Your answer should not involve asummation.

62

3. • Part a): In a simple graph G = (V,E), there is a walk that starts at vertex x and endsat vertex y (x 6= y). Prove that there is a path joining x and y. [Refer to the handout onbasic terminology to remind yourself of the definitions: basically, a walk allows repetitionof vertices and edges, a path does not.]

• Part b): In a simple graph G = (V,E), there is a closed walk of odd length. Prove thatthere is a cycle of odd length. [Again, refer to the handout on basic terminology; thelength of a walk, path etc. is the number of edges in it.]

63

4. The n-dimensional hypercube Qn is the graph whose vertex set is the set of all vectors(x1, . . . , xn) with each xi = 0 or 1 (so there are 2n vertices), with two vertices adjacent ifthe two vectors differ on exactly one coordinate. (So the graph Q2 is just the usual square,and Q3 is the familiar three dimensional cube). Here are pictures of the 0-, 1-, 2-, 3- and4-dimensional hypercubes:

• Part a): What is the degree of each vertex in Qn?

• Part b): How many edges does Qn have?

64

• Part c): For which n does Qn have a closed Eulerian trail? Briefly justify your answer.

• Part d): Prove that for n ≥ 2, Qn has a Hamiltonian cycle.

65

16 Quiz 3 (March 30) Name:

1. Draw an example of a graph that has a closed Eulerian trail but does not have a Hamiltonian cycle.Mark the closed Eulerian trail clearly, and explain clearly why the graph you have drawn does nothave a Hamiltonian cycle.

2. Remember that a cycle in a graph is a sequence of distinct vertices (v1, . . . , v`) with each of the followingbeing edges of the graph: v1v2, v2v3, . . . , v`−1v`, and v`v1. Prove that if G is a simple graph in whichthe degree of each vertex is at least 2, then G has a cycle.

66

17 Homework 7 (due April 20) Name:

The purpose of this homework is to explore properties of graphs and trees.

Reading: Chapter9, section 4 and Chapter 10, section 1.

1. • Part a): In class we proved that if G is a finite connected graph with all degrees even,then G has a closed Euulerian trail. By giving an example of a connected graph withinfinitely many vertices, connected, all degrees even, with no closed Eulerian trail, showthat the hypothesis that G is finite is needed in the theorem we proved.

• part b): Explain why the proof we gave in class, of the fact that a finite connected graphwith all degrees even has a closed Euulerian trail, goes wrong when G is infinite (pointout exactly the place where the proof breaks down).

67

2. • Part a): In class we proved the following: “If G is a connected (simple) graph on nvertices with all degrees at least n/2, then G has a Hamiltonian cycle”. Show that thehypothesis that G is connected is unnecessary here. Namely, show that if G is a (simple)graph on n vertices with all degrees at least n/2, then it must be connected.

• Part b): Show that the theorem we proved in class cannot be improved, in the followingsense: for each even n ≥ 4, give an example of a graph on n vertices with all degrees atleast (n/2)− 1, but without a Hamiltonian cycle.

68

3. • Part a): Prove that every tree on n ≥ 2 vertices has at least 2 leaves. Your proof MUSTbegin as follows: “Let T be a tree on n ≥ 2 vertices. Let P = x1x2 . . . xm be a longestpath in T . Note that since n ≥ 2, T has at least one edge, so the longest path in T has atleast one edge, and so x1 6= xm”. The rest of the proof must use P in some fundamentalway! [Note: there is no need to re-write the part of the proof that I’ve written above.]

• Part b): Prove that if a tree T has a vertex of degree 10 then it has at least 10 leaves.

69

4. Show constructively that for each n there are at least 1 +(n2

)non-isomorphic graphs on n

vertices, by explicitly describing 1 +(n2

)graphs on vertex set {1, . . . , n} no two of which are

isomorphic.

70

18 Homework 8 (due April 29) Name:

The purpose of this homework is to explore trees, Cayley’s formula, Prufer codes, spanning trees,Kruskal’s algorithm, and the adjacency matrix.

Reading: Chapter 10 (note that Prufer codes are covered in Exercise 5, page 234, and itssolution, page 239).

1. Let T be a tree whose longest path is length k (k edges). Let P1, P2 be two different paths inT , both of length k. Show that P1 and P2 must have a vertex in common.

71

2. A tree on vertex set {1, . . . , n} has Prufer code nnn . . . n (n − 2 n’s). Draw the tree in thespace below.

3. How can you tell by looking at the Prufer code of a tree on vertex set {1, . . . , n}, that the treeis a path? [Without, of course, just building the tree from the code ... you should describe away that just involves scanning the code].

72

4. Let G be a graph (not necessarily connected) on n vertices {v1, . . . , vn}. Put weights on theedges of the complete graph on vertex set {v1, . . . , vn} as follows: if vivj ∈ E(G), set w(vivj) =0, and if vivj 6∈ E(G), set w(vivj) = 1. Run Kruskal’s algorithm on this weighted completegraph. Explain (with justification!) how you can use the output of Kruskal’s algorithm todeduce the number of components that G has.

73

5. By using the Prufer code, find a formula for the number of trees on vertex set {1, . . . , n}(n ≥ 3) that have exactly k leaves (k between 2 and n − 1. Your formula should not involvea summation. [Hint: Think of the Prufer code as a function f : {1, . . . , n− 2} → {1, . . . , n},with f(i) being the number in the ith position of the code. If the tree has exactly k leaves,what do you know about the range of the function?]

74