cs 207 discrete mathematics 2012-2013 - iit bombaynutan/courses/cs207-12/notes/lec8.pdfi pigeonhole...

72
CS 207 Discrete Mathematics – 2012-2013 Nutan Limaye Indian Institute of Technology, Bombay [email protected] Combinatorics Lecture 8: Double counting August 14, 2012 Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 1/1

Upload: dokhue

Post on 22-May-2018

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

CS 207 Discrete Mathematics – 2012-2013

Nutan Limaye

Indian Institute of Technology, [email protected]

CombinatoricsLecture 8: Double counting

August 14, 2012

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 1 / 1

Page 2: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Course Outline

Mathematical reasoning and mathematical objects

Combinatorics

Elements of graph theory

Elements of abstract algebra

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 2 / 1

Page 3: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Course Outline

Mathematical reasoning and mathematical objects

I What is a proof? Types of proof methodsI InductionI Sets, relations, functions, partial orders, graphs

Combinatorics

Elements of graph theory

Elements of abstract algebra

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 2 / 1

Page 4: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Course Outline

Mathematical reasoning and mathematical objects

I What is a proof? Types of proof methodsI InductionI Sets, relations, functions, partial orders, graphs

Text: Discrete Mathematics and its applictions, by Kenneth RosenChapter 2 : 2.1, 2.2, 2.3, Chapter 8 : 8.1, 8.5, 8.6

Class notes: uploaded on Moodle

Combinatorics

Elements of graph theory

Elements of abstract algebra

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 2 / 1

Page 5: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Course Outline

Mathematical reasoning and mathematical objects

CombinatoricsI Double countingI Approximating sums and productsI Pigeonhole principleI Recurrence relations and generating functionsI Inclusion-exclusion principleI Elements of discrete probability

Elements of graph theory

Elements of abstract algebra

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 2 / 1

Page 6: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Course Outline

Mathematical reasoning and mathematical objects

CombinatoricsI Double countingI Approximating sums and productsI Pigeonhole principleI Recurrence relations and generating functionsI Inclusion-exclusion principleI Elements of discrete probability

Text: Discrete Mathematics and its applictions, by Kenneth RosenChapter 5, Chapter 6 : 6.1, 6.4, Chapter 7

Class notes: uploaded on Moodle

Elements of graph theory

Elements of abstract algebra

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 2 / 1

Page 7: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 8: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 9: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

I There are n2 ordered pairs of elements if the set is of size n.

I We are required to put a pair of the form (x , x) in a reflexive relationfor each x ∈ A.

I The rest of pairs, n2 − n of them, may or may not be put.I Therefore, there are 2n2−n different reflexive relations.

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 10: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

I There are n2 ordered pairs of elements if the set is of size n.I We are required to put a pair of the form (x , x) in a reflexive relation

for each x ∈ A.

I The rest of pairs, n2 − n of them, may or may not be put.I Therefore, there are 2n2−n different reflexive relations.

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 11: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

I There are n2 ordered pairs of elements if the set is of size n.I We are required to put a pair of the form (x , x) in a reflexive relation

for each x ∈ A.I The rest of pairs, n2 − n of them, may or may not be put.

I Therefore, there are 2n2−n different reflexive relations.

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 12: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

I There are n2 ordered pairs of elements if the set is of size n.I We are required to put a pair of the form (x , x) in a reflexive relation

for each x ∈ A.I The rest of pairs, n2 − n of them, may or may not be put.I Therefore, there are 2n2−n different reflexive relations.

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 13: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 14: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

I On LHS, fix a k. Then(nk

)is basically the number of ways of choosing

k people from n people. By summing over k , we are essentiallycounting the total number of ways of forming a committee from a setof n people.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 15: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

I On LHS, fix a k. Then(nk

)is basically the number of ways of choosing

k people from n people. By summing over k , we are essentiallycounting the total number of ways of forming a committee from a setof n people.

I However, that is the same as counting all possible subsets of a set ofsize n, which we know is 2n.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 16: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Warm up exercises:

How many reflexive relations are there on a set, say A, of size n?

Prove thatn∑

k=0

(n

k

)= 2n

I Of course, one could give an inductive proof. However, here is anotherproof.

I On LHS, fix a k. Then(nk

)is basically the number of ways of choosing

k people from n people. By summing over k , we are essentiallycounting the total number of ways of forming a committee from a setof n people.

I However, that is the same as counting all possible subsets of a set ofsize n, which we know is 2n.

I As LHS and RHS are counting the same quantity they must be equal.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 3 / 1

Page 17: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 18: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

I Let S =∑n

i=1 i

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 19: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

I Let S =∑n

i=1 iI

S =1+ 2+ . . .+ n

n+ (n − 1)+ . . .+ 1

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

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 20: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

I Let S =∑n

i=1 iI

S =1+ 2+ . . .+ n

n+ (n − 1)+ . . .+ 1

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

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 21: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

I Therefore, S = n(n+1)2 .

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 22: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 23: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:I Let S =

∑ni=0 x

i

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 24: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:I Let S =

∑ni=0 x

i

I

S =1+ x+ . . .+ xn (1)

xS =x+ x2+ . . .+ xn+1 (2)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 25: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:I Let S =

∑ni=0 x

i

I

S =1+ x+ . . .+ xn (1)

xS =x+ x2+ . . .+ xn+1 (2)

(1)-(2) gives us: (1− x)S = 1− xn+1

I Therefore, S = 1−xn+1

1−x .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 26: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly hard exercises: (Gauss Pertubations)

Prove that∑n

i=1 i = n(n+1)2

I Of course, one could give an inductive proof. But here is a cool way toprove the same:

Prove that 1 + x + . . . + xn = 1−xn+1

1−xI Of course, one could give an inductive proof. But here is a cool way to

prove the same:

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 4 / 1

Page 27: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 28: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 29: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is

n!I We will see that the fraction of n! which is addressed wrongly is almost

1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 30: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 31: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 32: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:

I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 33: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.

I Each round: player 1 draws a line using a red pen and then player 2draws a line using a blue pen.

I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 34: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.

I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 35: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.

I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 36: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?

I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 37: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Let us count

Slightly harder exercises:

Given n envelopes with addresses and n letters, how many are thereto arrange them so that no letter goes to its correct address?

I The total number of ways of putting n distinct letters into n distinctenvelopes is n!

I We will see that the fraction of n! which is addressed wrongly is almost1/e, where e is the base of the natural logarithm.

A two-player game. I need any two of you to come to the board:I I will draw 6 points on the board.I Each round: player 1 draws a line using a red pen and then player 2

draws a line using a blue pen.I Who loses?: The first person to draw a triangle of his/her colour.I Can this game ever end in a draw?I Ramsey proved that a draw is impossible!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 5 / 1

Page 38: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Why and how to count?

On various occasions different quantities may become interesting. Somemay be easy to count directly. Some may require more thought.

[CW] Count the number of arrangements of wrongly addresses letters forn = 4.

In this module, we will build some technqiues that will help in countingsome quantities which are hard to count.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 6 / 1

Page 39: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Why and how to count?

On various occasions different quantities may become interesting. Somemay be easy to count directly. Some may require more thought.

[CW] Count the number of arrangements of wrongly addresses letters forn = 4.

In this module, we will build some technqiues that will help in countingsome quantities which are hard to count.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 6 / 1

Page 40: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Today

We will spend this lecture to learn counting one object in two differentways.

Often to count a certain object, we will count some totally different object!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 7 / 1

Page 41: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Today

We will spend this lecture to learn counting one object in two differentways.Often to count a certain object, we will count some totally different object!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 7 / 1

Page 42: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)

Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first and then pick oneamong them as a leader to get k

(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 43: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Recall(nk

)= n!

k!(n−k)!

Given n players, how many ways are there to pick ateam of size k and one leader among them?

Either you can choose k members of a team first and then pick oneamong them as a leader to get k

(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 44: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first and then pick oneamong them as a leader to get k

(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 45: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first and then pick oneamong them as a leader

to get k(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 46: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader

to get k(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 47: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader in k ways

to get k(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 48: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader in k ways to get k(nk

)Or you can first choose a leader and then choose the rest of thek − 1 team members from the remaining n − 1 players

to get n(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 49: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader in k ways to get k(nk

)Or you can first choose a leader in n ways and then choose the rest ofthe k − 1 team members from the remaining n − 1 players

to getn(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 50: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader in k ways to get k(nk

)Or you can first choose a leader in n ways and then choose the rest ofthe k − 1 team members from the remaining n − 1 players in

(n−1k−1

)ways

to get n(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 51: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

An example of double counting

Lemma

k(nk

)= n

(n−1k−1

)Proof.

Given n players, how many ways are there to pick a team of size k and oneleader among them?

Either you can choose k members of a team first in(nk

)ways and

then pick one among them as a leader in k ways to get k(nk

)Or you can first choose a leader in n ways and then choose the rest ofthe k − 1 team members from the remaining n − 1 players in

(n−1k−1

)ways to get n

(n−1k−1

)

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 8 / 1

Page 52: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Another example of double counting

Lemma

[CW](n+1

k

)=( nk−1

)+(nk

)

Proof.

Quantity to double count: Given a collection of n apples and 1 mango,the number of ways of choosing a basketof k fruit.

Note that, LHS equals this quantity.For the RHS, note that

Either choose the mango in the basket and select k − 1 apples from napples in

( nk−1

)ways.

Or leave out the mango from the basket and select k apples from napples in

(nk

)ways.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 9 / 1

Page 53: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Another example of double counting

Lemma

[CW](n+1

k

)=( nk−1

)+(nk

)Proof.

Quantity to double count: Given a collection of n apples and 1 mango,the number of ways of choosing a basketof k fruit.

Note that, LHS equals this quantity.

For the RHS, note that

Either choose the mango in the basket and select k − 1 apples from napples in

( nk−1

)ways.

Or leave out the mango from the basket and select k apples from napples in

(nk

)ways.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 9 / 1

Page 54: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Another example of double counting

Lemma

[CW](n+1

k

)=( nk−1

)+(nk

)Proof.

Quantity to double count: Given a collection of n apples and 1 mango,the number of ways of choosing a basketof k fruit.

Note that, LHS equals this quantity.For the RHS, note that

Either choose the mango in the basket and select k − 1 apples from napples in

( nk−1

)ways.

Or leave out the mango from the basket and select k apples from napples in

(nk

)ways.

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 9 / 1

Page 55: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 56: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.

Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 57: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.[CW] Check that what we want to prove is the same as:

Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 58: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.[CW] Check that what we want to prove is the same as:the number of vertices with odd degree is even.

Degree(v) := |{u | (u, v) ∈ E}| Let mi be the number of times person ishakes hands. We will count the number of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 59: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.[CW] Check that what we want to prove is the same as:the number of vertices with odd degree is even.Degree(v) := |{u | (u, v) ∈ E}|

Let mi be the number of times person ishakes hands. We will count the number of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 60: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.

On the one hand this number is∑n

i=1mi .

On the other hand each handshake gives rise to two edges. So if X isthe number of handshakes, then the number of edges is 2X .

∴ 2X =∑n

i=1mi .This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 61: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.

On the one hand this number is∑n

i=1mi .

On the other hand each handshake gives rise to two edges. So if X isthe number of handshakes, then the number of edges is 2X .

∴ 2X =∑n

i=1mi .This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 62: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 63: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 64: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 65: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

The number of handshakes

Lemma (The handshake lemma)

At a party with n people, the number of people who shake hands an oddnumber of times is even.

Proof.

Let us construct a graph with n people as vertices. We draw directededges (u, v) and (v , u) if u and v shake hands.Let mi be the number of times person i shakes hands. We will count thenumber of directed edges in the graph.∴ 2X =

∑ni=1mi .

This tells us that the sum of n numbers is even. Therefore, only evenmany of them can have odd value!

Take back message: Counting the same quantity the number of directededges in two different ways can be helpful!

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 10 / 1

Page 66: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 67: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.

[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 68: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?

Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 69: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.

∴ P =(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 70: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 71: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.

∴ n = m(m−1)6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1

Page 72: CS 207 Discrete Mathematics 2012-2013 - IIT Bombaynutan/courses/cs207-12/notes/lec8.pdfI Pigeonhole principle ... Discrete Mathematics and its applictions, ... Nutan (IITB) CS 207

Counting the same quantity in different ways

Lemma

Cosnider a class of m students. Every day after class 3 students stay backto clean the classes. At the end of the course, they realise that each pair ofstudents stayed back exactly once. For how many days did the course run?

Proof.

Say the course ran for n days.[CW] In a class of m students, how many distinct pairs of students arethere?Let P be the total number of distinct pairs of students.∴ P =

(m2

).

On the other hand, each day 3 pairs of students stay back together. Asthere are n days, P = 3n.∴ n = m(m−1)

6 .

Nutan (IITB) CS 207 Discrete Mathematics – 2012-2013 May 2011 11 / 1