the art of counting - bijections, double...

51
The Art of Counting Bijections, Double Counting Peng Shi Department of Mathematics Duke University September 16, 2009

Upload: others

Post on 17-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

The Art of CountingBijections, Double Counting

Peng Shi

Department of MathematicsDuke University

September 16, 2009

Page 2: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

What we focus on in this talk?

Enumerative combinatorics is a huge branchof mathematics, involving many theoremsand techniques, which we cannot hope tocover in one class

Today, we will consider some commonly-used paradigms of counting:

Straightforward, careful counting

Bijection

Counting in multiple ways

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 2/13

Page 3: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

What we focus on in this talk?

Enumerative combinatorics is a huge branchof mathematics, involving many theoremsand techniques, which we cannot hope tocover in one class

Today, we will consider some commonly-used paradigms of counting:

Straightforward, careful counting

Bijection

Counting in multiple ways

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 2/13

Page 4: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

What we focus on in this talk?

Enumerative combinatorics is a huge branchof mathematics, involving many theoremsand techniques, which we cannot hope tocover in one class

Today, we will consider some commonly-used paradigms of counting:

Straightforward, careful counting

Bijection

Counting in multiple ways

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 2/13

Page 5: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

What we focus on in this talk?

Enumerative combinatorics is a huge branchof mathematics, involving many theoremsand techniques, which we cannot hope tocover in one class

Today, we will consider some commonly-used paradigms of counting:

Straightforward, careful counting

Bijection

Counting in multiple ways

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 2/13

Page 6: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 1: Careful Straightforward Counting

Comprehensive enumeration/case work

Make sure to count every case

Don’t double count

Sum Rule:If A = A1

⋃A2

⋃· · ·⋃

An, Ai

⋂Aj = ∅, then

|A| = |A1|+ |A2|+ · · ·+ |An|

Product Rule:If W = W1 ×W2 × · · · ×Wn (Cartesian set product), then

|W | = |W1||W2| · · · |Wn|

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 3/13

Page 7: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 1: Careful Straightforward Counting

Comprehensive enumeration/case work

Make sure to count every case

Don’t double count

Sum Rule:If A = A1

⋃A2

⋃· · ·⋃

An, Ai

⋂Aj = ∅, then

|A| = |A1|+ |A2|+ · · ·+ |An|

Product Rule:If W = W1 ×W2 × · · · ×Wn (Cartesian set product), then

|W | = |W1||W2| · · · |Wn|

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 3/13

Page 8: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 1: Careful Straightforward Counting

Comprehensive enumeration/case work

Make sure to count every case

Don’t double count

Sum Rule:If A = A1

⋃A2

⋃· · ·⋃

An, Ai

⋂Aj = ∅, then

|A| = |A1|+ |A2|+ · · ·+ |An|

Product Rule:If W = W1 ×W2 × · · · ×Wn (Cartesian set product), then

|W | = |W1||W2| · · · |Wn|

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 3/13

Page 9: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Binomial Coefficients

How many subsets of {1, 2, · · · , n} are there with exactly m elements?

n ways to choose 1st element, n − 1 ways to choose 2nd, . . . Son(n − 1) · · · (n −m + 1)? But each subset is counted m! times

(nk

)= n(n−1)···(n−m+1)

m(m−1)···1= n!

(n−m)!m!

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 4/13

Page 10: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Binomial Coefficients

How many subsets of {1, 2, · · · , n} are there with exactly m elements?

n ways to choose 1st element, n − 1 ways to choose 2nd, . . . Son(n − 1) · · · (n −m + 1)?

But each subset is counted m! times

(nk

)= n(n−1)···(n−m+1)

m(m−1)···1= n!

(n−m)!m!

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 4/13

Page 11: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Binomial Coefficients

How many subsets of {1, 2, · · · , n} are there with exactly m elements?

n ways to choose 1st element, n − 1 ways to choose 2nd, . . . Son(n − 1) · · · (n −m + 1)? But each subset is counted m! times

(nk

)= n(n−1)···(n−m+1)

m(m−1)···1= n!

(n−m)!m!

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 4/13

Page 12: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Binomial Coefficients

How many subsets of {1, 2, · · · , n} are there with exactly m elements?

n ways to choose 1st element, n − 1 ways to choose 2nd, . . . Son(n − 1) · · · (n −m + 1)? But each subset is counted m! times

(nk

)= n(n−1)···(n−m+1)

m(m−1)···1= n!

(n−m)!m!

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 4/13

Page 13: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Inclusion-Exclusion PrincipleIf we know A = A1

⋃· · ·⋃

An but the Ai ’s are not necessarily disjoint,how do we count |A|?

Example: suppose |A| = 9, |B| = 6,|C | = 9, |A

⋂B| = 3, |A

⋂C | = 4,

|B⋂

C | = 2, |A⋂

B⋂

C | = 1, whatis |A

⋃B⋃

C |?

|A⋃

B⋃

C |= |A|+ |B|+ |C | − |A

⋂B| − |A

⋂C | − |B

⋂C |+ |A

⋂B⋂

C |= 9 + 6 + 9− 3− 4− 2 + 1= 16

In general,

|A1

⋃· · ·⋃

An| =∑

i

|Ai | −∑i<j

|Ai

⋂Aj |+

∑i<j<k

|Ai

⋂Aj

⋂Ak | · · ·

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 5/13

Page 14: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Inclusion-Exclusion PrincipleIf we know A = A1

⋃· · ·⋃

An but the Ai ’s are not necessarily disjoint,how do we count |A|?

Example: suppose |A| = 9, |B| = 6,|C | = 9, |A

⋂B| = 3, |A

⋂C | = 4,

|B⋂

C | = 2, |A⋂

B⋂

C | = 1, whatis |A

⋃B⋃

C |?

|A⋃

B⋃

C |= |A|+ |B|+ |C | − |A

⋂B| − |A

⋂C | − |B

⋂C |+ |A

⋂B⋂

C |= 9 + 6 + 9− 3− 4− 2 + 1= 16

In general,

|A1

⋃· · ·⋃

An| =∑

i

|Ai | −∑i<j

|Ai

⋂Aj |+

∑i<j<k

|Ai

⋂Aj

⋂Ak | · · ·

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 5/13

Page 15: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Inclusion-Exclusion PrincipleIf we know A = A1

⋃· · ·⋃

An but the Ai ’s are not necessarily disjoint,how do we count |A|?

Example: suppose |A| = 9, |B| = 6,|C | = 9, |A

⋂B| = 3, |A

⋂C | = 4,

|B⋂

C | = 2, |A⋂

B⋂

C | = 1, whatis |A

⋃B⋃

C |?

|A⋃

B⋃

C |= |A|+ |B|+ |C | − |A

⋂B| − |A

⋂C | − |B

⋂C |+ |A

⋂B⋂

C |= 9 + 6 + 9− 3− 4− 2 + 1= 16

In general,

|A1

⋃· · ·⋃

An| =∑

i

|Ai | −∑i<j

|Ai

⋂Aj |+

∑i<j<k

|Ai

⋂Aj

⋂Ak | · · ·

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 5/13

Page 16: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Basic Tool: Inclusion-Exclusion PrincipleIf we know A = A1

⋃· · ·⋃

An but the Ai ’s are not necessarily disjoint,how do we count |A|?

Example: suppose |A| = 9, |B| = 6,|C | = 9, |A

⋂B| = 3, |A

⋂C | = 4,

|B⋂

C | = 2, |A⋂

B⋂

C | = 1, whatis |A

⋃B⋃

C |?

|A⋃

B⋃

C |= |A|+ |B|+ |C | − |A

⋂B| − |A

⋂C | − |B

⋂C |+ |A

⋂B⋂

C |= 9 + 6 + 9− 3− 4− 2 + 1= 16

In general,

|A1

⋃· · ·⋃

An| =∑

i

|Ai | −∑i<j

|Ai

⋂Aj |+

∑i<j<k

|Ai

⋂Aj

⋂Ak | · · ·

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 5/13

Page 17: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Putting the theory into practiceExample 1[Derangements] Aat a Secret Santa party, there are n guests, who eachbrings a present. Once all presents are collected, they are permutedrandomly, and redistributed to the guests. What is the probability noguest receives his/her own gift? What does this converge to as n→∞?

Solution.Let the set of all permultations of {1, 2, · · · , n} be U. Let D ⊂ U be the

set of permutations without fixed points. We seek |D||U| . Let

Ai = { permutationπ|π(i) = i}. Then D = U\(A1

⋃A2

⋃· · ·⋃

An).

|A1

⋃· · ·⋃

An| =∑

i |Ai | −∑

i<j |Ai

⋂Aj | · · ·

= (n − 1)!−(n2

)(n − 2)! +

(n3

)(n − 3)!

= n!∑n

i=1(−1)i+1

i!

The probability is

|D||U|

=n∑

i=0

(−1)i

i !→ 1

e

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 6/13

Page 18: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Putting the theory into practiceExample 1[Derangements] Aat a Secret Santa party, there are n guests, who eachbrings a present. Once all presents are collected, they are permutedrandomly, and redistributed to the guests. What is the probability noguest receives his/her own gift? What does this converge to as n→∞?

Solution.Let the set of all permultations of {1, 2, · · · , n} be U. Let D ⊂ U be the

set of permutations without fixed points. We seek |D||U| .

Let

Ai = { permutationπ|π(i) = i}. Then D = U\(A1

⋃A2

⋃· · ·⋃

An).

|A1

⋃· · ·⋃

An| =∑

i |Ai | −∑

i<j |Ai

⋂Aj | · · ·

= (n − 1)!−(n2

)(n − 2)! +

(n3

)(n − 3)!

= n!∑n

i=1(−1)i+1

i!

The probability is

|D||U|

=n∑

i=0

(−1)i

i !→ 1

e

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 6/13

Page 19: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Putting the theory into practiceExample 1[Derangements] Aat a Secret Santa party, there are n guests, who eachbrings a present. Once all presents are collected, they are permutedrandomly, and redistributed to the guests. What is the probability noguest receives his/her own gift? What does this converge to as n→∞?

Solution.Let the set of all permultations of {1, 2, · · · , n} be U. Let D ⊂ U be the

set of permutations without fixed points. We seek |D||U| . Let

Ai = { permutationπ|π(i) = i}. Then D = U\(A1

⋃A2

⋃· · ·⋃

An).

|A1

⋃· · ·⋃

An| =∑

i |Ai | −∑

i<j |Ai

⋂Aj | · · ·

= (n − 1)!−(n2

)(n − 2)! +

(n3

)(n − 3)!

= n!∑n

i=1(−1)i+1

i!

The probability is

|D||U|

=n∑

i=0

(−1)i

i !→ 1

e

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 6/13

Page 20: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Putting the theory into practiceExample 1[Derangements] Aat a Secret Santa party, there are n guests, who eachbrings a present. Once all presents are collected, they are permutedrandomly, and redistributed to the guests. What is the probability noguest receives his/her own gift? What does this converge to as n→∞?

Solution.Let the set of all permultations of {1, 2, · · · , n} be U. Let D ⊂ U be the

set of permutations without fixed points. We seek |D||U| . Let

Ai = { permutationπ|π(i) = i}. Then D = U\(A1

⋃A2

⋃· · ·⋃

An).

|A1

⋃· · ·⋃

An| =∑

i |Ai | −∑

i<j |Ai

⋂Aj | · · ·

= (n − 1)!−(n2

)(n − 2)! +

(n3

)(n − 3)!

= n!∑n

i=1(−1)i+1

i!

The probability is

|D||U|

=n∑

i=0

(−1)i

i !→ 1

e

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 6/13

Page 21: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Putting the theory into practiceExample 1[Derangements] Aat a Secret Santa party, there are n guests, who eachbrings a present. Once all presents are collected, they are permutedrandomly, and redistributed to the guests. What is the probability noguest receives his/her own gift? What does this converge to as n→∞?

Solution.Let the set of all permultations of {1, 2, · · · , n} be U. Let D ⊂ U be the

set of permutations without fixed points. We seek |D||U| . Let

Ai = { permutationπ|π(i) = i}. Then D = U\(A1

⋃A2

⋃· · ·⋃

An).

|A1

⋃· · ·⋃

An| =∑

i |Ai | −∑

i<j |Ai

⋂Aj | · · ·

= (n − 1)!−(n2

)(n − 2)! +

(n3

)(n − 3)!

= n!∑n

i=1(−1)i+1

i!

The probability is

|D||U|

=n∑

i=0

(−1)i

i !→ 1

e

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 6/13

Page 22: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 2: Constructing a BijectionA bijection is a one-to-one correspondence:

Given sets A,B, a bijection f is f : A→ B that is one-to-one (no twoelements in A are mapped to the same in B) and onto (for every elementin B, some element in A maps to it.)

Equivalently, f is a bijection if there is an inverse map: ∃g : B → A, s.t.∀a ∈ A, g(f (a)) = a.

We frequently show that two sets are equal in size by constructing abijection.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 7/13

Page 23: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 2: Constructing a BijectionA bijection is a one-to-one correspondence:

Given sets A,B, a bijection f is f : A→ B that is one-to-one (no twoelements in A are mapped to the same in B) and onto (for every elementin B, some element in A maps to it.)

Equivalently, f is a bijection if there is an inverse map: ∃g : B → A, s.t.∀a ∈ A, g(f (a)) = a.

We frequently show that two sets are equal in size by constructing abijection.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 7/13

Page 24: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple BijectionExample 2(CMO 2005) Consider an equilateral triangle of side length n, which isdivided into unit triangles, as shown. Let f (n) be the number of pathsfrom the triangle in the top row to the middle triangle in the bottom row,such that adjacent triangles in our path share a common edge and thepath never travels up (from a lower row to a higher row) or revisits atriangle. An example of one such path is illustrated below for n = 5.Determine the value of f (2005).

Solution.We show that there is a bijective mapping between valid paths andordered lists (a1, a2, · · · , an), where 1 ≤ ai ≤ i . Essentially ai indicateswhere the path “exit” the ith row and enter the i + 1th row. For anyvalid path, this ordered lists exists. For any ordered list, we canreconstruct the path uniquely. The number of such ordered lists isexactly n!, hence f (2005) = 2005!.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 8/13

Page 25: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Bijection

Solution.We show that there is a bijective mapping between valid paths andordered lists (a1, a2, · · · , an), where 1 ≤ ai ≤ i . Essentially ai indicateswhere the path “exit” the ith row and enter the i + 1th row. For anyvalid path, this ordered lists exists. For any ordered list, we canreconstruct the path uniquely. The number of such ordered lists isexactly n!, hence f (2005) = 2005!.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 8/13

Page 26: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

More Involved BijectionExample 3(Catalan Numbers) In a n × n grid, we draw rectilinear paths from (0, 0)to (n, n), going only in positive x and y directions. How many such pathsare there that stay below the line y = x?

Answer:Cn = 1

n+1

(2nn

)=(2nn

)−(

2nn−1

)Proof.It suffices to show that the # of paths that cross the line is

(2n

n−1

). But

this is exactly the # of paths from (0, 0) to (n − 1, n + 1). So try to findbijection.

A path crosses y = x iff it touchesy = x + 1. Map f : take the first time thepath touches y = x + 1 and reflect thefollowing subpath across y = x + 1. Inversemap: app paths from (0, 0) to (n− 1, n + 1)touch y = x + 1. Take the first touch, andreflect the following subpath acrossy = x + 1. The maps are inverses becausethe first touch is preserved by both maps.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 9/13

Page 27: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

More Involved BijectionExample 3(Catalan Numbers) In a n × n grid, we draw rectilinear paths from (0, 0)to (n, n), going only in positive x and y directions. How many such pathsare there that stay below the line y = x?

Answer:Cn = 1

n+1

(2nn

)=(2nn

)−(

2nn−1

)

Proof.It suffices to show that the # of paths that cross the line is

(2n

n−1

). But

this is exactly the # of paths from (0, 0) to (n − 1, n + 1). So try to findbijection.

A path crosses y = x iff it touchesy = x + 1. Map f : take the first time thepath touches y = x + 1 and reflect thefollowing subpath across y = x + 1. Inversemap: app paths from (0, 0) to (n− 1, n + 1)touch y = x + 1. Take the first touch, andreflect the following subpath acrossy = x + 1. The maps are inverses becausethe first touch is preserved by both maps.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 9/13

Page 28: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

More Involved BijectionExample 3(Catalan Numbers) In a n × n grid, we draw rectilinear paths from (0, 0)to (n, n), going only in positive x and y directions. How many such pathsare there that stay below the line y = x?

Answer:Cn = 1

n+1

(2nn

)=(2nn

)−(

2nn−1

)Proof.It suffices to show that the # of paths that cross the line is

(2n

n−1

).

Butthis is exactly the # of paths from (0, 0) to (n − 1, n + 1). So try to findbijection.

A path crosses y = x iff it touchesy = x + 1. Map f : take the first time thepath touches y = x + 1 and reflect thefollowing subpath across y = x + 1. Inversemap: app paths from (0, 0) to (n− 1, n + 1)touch y = x + 1. Take the first touch, andreflect the following subpath acrossy = x + 1. The maps are inverses becausethe first touch is preserved by both maps.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 9/13

Page 29: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

More Involved BijectionExample 3(Catalan Numbers) In a n × n grid, we draw rectilinear paths from (0, 0)to (n, n), going only in positive x and y directions. How many such pathsare there that stay below the line y = x?

Answer:Cn = 1

n+1

(2nn

)=(2nn

)−(

2nn−1

)Proof.It suffices to show that the # of paths that cross the line is

(2n

n−1

). But

this is exactly the # of paths from (0, 0) to (n − 1, n + 1). So try to findbijection.

A path crosses y = x iff it touchesy = x + 1. Map f : take the first time thepath touches y = x + 1 and reflect thefollowing subpath across y = x + 1. Inversemap: app paths from (0, 0) to (n− 1, n + 1)touch y = x + 1. Take the first touch, andreflect the following subpath acrossy = x + 1. The maps are inverses becausethe first touch is preserved by both maps.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 9/13

Page 30: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

More Involved BijectionExample 3(Catalan Numbers) In a n × n grid, we draw rectilinear paths from (0, 0)to (n, n), going only in positive x and y directions. How many such pathsare there that stay below the line y = x?

Answer:Cn = 1

n+1

(2nn

)=(2nn

)−(

2nn−1

)Proof.It suffices to show that the # of paths that cross the line is

(2n

n−1

). But

this is exactly the # of paths from (0, 0) to (n − 1, n + 1). So try to findbijection.

A path crosses y = x iff it touchesy = x + 1. Map f : take the first time thepath touches y = x + 1 and reflect thefollowing subpath across y = x + 1. Inversemap: app paths from (0, 0) to (n− 1, n + 1)touch y = x + 1. Take the first touch, andreflect the following subpath acrossy = x + 1. The maps are inverses becausethe first touch is preserved by both maps.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 9/13

Page 31: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 3: Counting in Multiple Ways

Sometimes we want to count some set S in multiple ways, and usethe resulting equality for our proof

We may need to creatively define S ourselves (think outside the box)

Counting something in multiple ways may provide powerful insight

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 10/13

Page 32: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 3: Counting in Multiple Ways

Sometimes we want to count some set S in multiple ways, and usethe resulting equality for our proof

We may need to creatively define S ourselves (think outside the box)

Counting something in multiple ways may provide powerful insight

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 10/13

Page 33: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 3: Counting in Multiple Ways

Sometimes we want to count some set S in multiple ways, and usethe resulting equality for our proof

We may need to creatively define S ourselves (think outside the box)

Counting something in multiple ways may provide powerful insight

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 10/13

Page 34: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 3: Counting in Multiple Ways

Sometimes we want to count some set S in multiple ways, and usethe resulting equality for our proof

We may need to creatively define S ourselves (think outside the box)

Counting something in multiple ways may provide powerful insight

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 10/13

Page 35: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Paradigm 3: Counting in Multiple Ways

Sometimes we want to count some set S in multiple ways, and usethe resulting equality for our proof

We may need to creatively define S ourselves (think outside the box)

Counting something in multiple ways may provide powerful insight

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 10/13

Page 36: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)There are n days and each day there are 3 pairs. So P = 3nOn the other hand P =

(152

)Hence, n = 1

2

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 37: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)There are n days and each day there are 3 pairs. So P = 3nOn the other hand P =

(152

)Hence, n = 1

2

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 38: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)

There are n days and each day there are 3 pairs. So P = 3nOn the other hand P =

(152

)Hence, n = 1

2

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 39: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)There are n days and each day there are 3 pairs. So P = 3n

On the other hand P =(152

)Hence, n = 1

2

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 40: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)There are n days and each day there are 3 pairs. So P = 3nOn the other hand P =

(152

)

Hence, n = 12

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 41: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Simple Example

Example 415 students join a summer course. Every day, 3 students are on dutyafter school to clean the classroom. After the course, it was found thatevery pair of students has been on duty together exactly once. Howmany days does the course last for?

What can we count in two ways?

Solution.We count the total number P of pairs of students who work together forall days. (Pairs are considered different if the same pairing happens ondifferent days.)There are n days and each day there are 3 pairs. So P = 3nOn the other hand P =

(152

)Hence, n = 1

2

(152

)= 35.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 11/13

Page 42: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Example 5(CMO 2006) There are 2n + 1 teams in a round-robin tournament, inwhich each team plays every other team exactly once, with no ties. Wesay that teams X , Y , Z form a cycle triplet if X beats Y , Y beats Z andZ beats X . Determine the maximum number of cyclic triplets possible.

Proof.Count the # of the following types of “angles”

Each cyclic triangle has 3 type C angles, while eachnon-cyclic triagle has 1 angle of each time.

(# of non-cyclic triangles)= 1

2 [(# of type A angles) + (# of type B angles)]

= 12

∑2n+1i=1

(ai

2

)+(2n−ai

2

)≥ 1

2

∑2n+1i=1

(n2

)+(n2

)= n(n−1)(2n+1)

2

Hence, the # of cyclic triangles is at least(2n+1

3

)− n(n−1)(2n+1)

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

To show this bound can be attained, label the vertices 1, 2, · · · , 2n + 1and put directed edge i → j iff j − i( mod 2n + 1) ∈ {1, 2, · · · , n}.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 12/13

Page 43: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Example 5(CMO 2006) There are 2n + 1 teams in a round-robin tournament, inwhich each team plays every other team exactly once, with no ties. Wesay that teams X , Y , Z form a cycle triplet if X beats Y , Y beats Z andZ beats X . Determine the maximum number of cyclic triplets possible.

Proof.Count the # of the following types of “angles”

Each cyclic triangle has 3 type C angles, while eachnon-cyclic triagle has 1 angle of each time.

(# of non-cyclic triangles)= 1

2 [(# of type A angles) + (# of type B angles)]

= 12

∑2n+1i=1

(ai

2

)+(2n−ai

2

)≥ 1

2

∑2n+1i=1

(n2

)+(n2

)= n(n−1)(2n+1)

2

Hence, the # of cyclic triangles is at least(2n+1

3

)− n(n−1)(2n+1)

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

To show this bound can be attained, label the vertices 1, 2, · · · , 2n + 1and put directed edge i → j iff j − i( mod 2n + 1) ∈ {1, 2, · · · , n}.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 12/13

Page 44: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Example 5(CMO 2006) There are 2n + 1 teams in a round-robin tournament, inwhich each team plays every other team exactly once, with no ties. Wesay that teams X , Y , Z form a cycle triplet if X beats Y , Y beats Z andZ beats X . Determine the maximum number of cyclic triplets possible.

Proof.Count the # of the following types of “angles”

Each cyclic triangle has 3 type C angles, while eachnon-cyclic triagle has 1 angle of each time.

(# of non-cyclic triangles)= 1

2 [(# of type A angles) + (# of type B angles)]

= 12

∑2n+1i=1

(ai

2

)+(2n−ai

2

)≥ 1

2

∑2n+1i=1

(n2

)+(n2

)= n(n−1)(2n+1)

2

Hence, the # of cyclic triangles is at least(2n+1

3

)− n(n−1)(2n+1)

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

To show this bound can be attained, label the vertices 1, 2, · · · , 2n + 1and put directed edge i → j iff j − i( mod 2n + 1) ∈ {1, 2, · · · , n}.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 12/13

Page 45: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Example 5(CMO 2006) There are 2n + 1 teams in a round-robin tournament, inwhich each team plays every other team exactly once, with no ties. Wesay that teams X , Y , Z form a cycle triplet if X beats Y , Y beats Z andZ beats X . Determine the maximum number of cyclic triplets possible.

Proof.Count the # of the following types of “angles”

Each cyclic triangle has 3 type C angles, while eachnon-cyclic triagle has 1 angle of each time.

(# of non-cyclic triangles)= 1

2 [(# of type A angles) + (# of type B angles)]

= 12

∑2n+1i=1

(ai

2

)+(2n−ai

2

)≥ 1

2

∑2n+1i=1

(n2

)+(n2

)= n(n−1)(2n+1)

2

Hence, the # of cyclic triangles is at least(2n+1

3

)− n(n−1)(2n+1)

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

To show this bound can be attained, label the vertices 1, 2, · · · , 2n + 1and put directed edge i → j iff j − i( mod 2n + 1) ∈ {1, 2, · · · , n}.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 12/13

Page 46: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Example 5(CMO 2006) There are 2n + 1 teams in a round-robin tournament, inwhich each team plays every other team exactly once, with no ties. Wesay that teams X , Y , Z form a cycle triplet if X beats Y , Y beats Z andZ beats X . Determine the maximum number of cyclic triplets possible.

Proof.Count the # of the following types of “angles”

Each cyclic triangle has 3 type C angles, while eachnon-cyclic triagle has 1 angle of each time.

(# of non-cyclic triangles)= 1

2 [(# of type A angles) + (# of type B angles)]

= 12

∑2n+1i=1

(ai

2

)+(2n−ai

2

)≥ 1

2

∑2n+1i=1

(n2

)+(n2

)= n(n−1)(2n+1)

2

Hence, the # of cyclic triangles is at least(2n+1

3

)− n(n−1)(2n+1)

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

To show this bound can be attained, label the vertices 1, 2, · · · , 2n + 1and put directed edge i → j iff j − i( mod 2n + 1) ∈ {1, 2, · · · , n}.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 12/13

Page 47: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Conclusion

Count carefully / don’t be sloppy

Be creative (Sometimes constructing the bijection or figuring outwhat set to count takes cleverness/randomness/luck)

Don’t give up!

Enjoy problem set 3! All problems have nice solutions, so try not to bruteforce.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 13/13

Page 48: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Conclusion

Count carefully / don’t be sloppy

Be creative (Sometimes constructing the bijection or figuring outwhat set to count takes cleverness/randomness/luck)

Don’t give up!

Enjoy problem set 3! All problems have nice solutions, so try not to bruteforce.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 13/13

Page 49: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Conclusion

Count carefully / don’t be sloppy

Be creative (Sometimes constructing the bijection or figuring outwhat set to count takes cleverness/randomness/luck)

Don’t give up!

Enjoy problem set 3! All problems have nice solutions, so try not to bruteforce.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 13/13

Page 50: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Conclusion

Count carefully / don’t be sloppy

Be creative (Sometimes constructing the bijection or figuring outwhat set to count takes cleverness/randomness/luck)

Don’t give up!

Enjoy problem set 3! All problems have nice solutions, so try not to bruteforce.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 13/13

Page 51: The Art of Counting - Bijections, Double Countingfaculty.marshall.usc.edu/Peng-Shi/math149/counting.pdf · [Derangements] Aat a Secret Santa party, there are n guests, who each brings

Conclusion

Count carefully / don’t be sloppy

Be creative (Sometimes constructing the bijection or figuring outwhat set to count takes cleverness/randomness/luck)

Don’t give up!

Enjoy problem set 3! All problems have nice solutions, so try not to bruteforce.

Peng Shi, Duke University The Art of Counting, Bijections, Double Counting 13/13