103
Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations and Combinations. Binomial and Multinomial Numbers Isabela Dr˘ amnesc UVT Computer Science Department, West University of Timi¸ soara, Romania October 1, 2018 Isabela Dr˘ amnesc UVT Graph Theory and Combinatorics – Lecture 1 1 / 31

Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Graph Theory and CombinatoricsLecture 1: Introduction.

Counting Principles. Permutations and Combinations.Binomial and Multinomial Numbers

Isabela Dramnesc UVT

Computer Science Department,West University of Timisoara,

Romania

October 1, 2018

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 1 / 31

Page 2: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Purpose of this lecture

Become familiar with the basic notions from combinatorics andgraph theory.

1 Counting principles, Arrangements, permutations,combinations.

2 Principle of inclusion and exclusion, enumeration techniques.3 Combinations4 The cyclic structure of permutations. Advanced counting

techniques.5 Polya’s theory of counting6 Graph theory: basic notions7 Data structures for the representation of graphs8 Transport networks, maximal flows, minimal cuts9 Trees: definitions; generating trees; minimum cost trees

10 Paths, circuits, chains, and cycles11 The traveling salesman problem. Planar graphs12 Chromatic theory of graphs13 Matchings

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 2 / 31

Page 3: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Organizatorial items

Lecturer and TA: Isabela Dramnesc

Course webpage: staff.fmi.uvt.ro/~isabela.dramnesc

ExercisesSeminar/Lab: working with Combinatorica in Mathematica

Handouts: will be posted on the webpage of the lecture

Grading:

50% : weekly seminar assignments and a partial exam (week 8)50% : 1 written exam at the end of the semester

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 3 / 31

Page 4: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Lecture outline

Basic counting principles

The product ruleThe sum ruleCombinatorial proofs; examples

Counting techniques for

combinations - unordered selections of distinct elements of afinite setpermutations - ordered selections of distinct elements of afinite set

Generalizations

permutations with repetitioncombinations with repetitionpermutations with indistinguishable elements

Binomial and multinomial numbers

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 4 / 31

Page 5: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Basic counting principles1. The product rule

Product rule. If a procedure can be broken down into a sequence of twotasks, such that

first task can be done in n1 wayssecond task can be done in n2 ways

then there are n1 · n2 ways to do the procedure.

Generalized product rule. If a procedure can be broken down into asequence of m tasks, such that

first task can be done in n1 wayssecond task can be done in n2 ways. . .m-th task can be done in nm ways

then there are n1 · n2 · . . . · nm ways to do the procedure.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 5 / 31

Page 6: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Basic counting principles1. The product rule

Product rule. If a procedure can be broken down into a sequence of twotasks, such that

first task can be done in n1 wayssecond task can be done in n2 ways

then there are n1 · n2 ways to do the procedure.

Generalized product rule. If a procedure can be broken down into asequence of m tasks, such that

first task can be done in n1 wayssecond task can be done in n2 ways. . .m-th task can be done in nm ways

then there are n1 · n2 · . . . · nm ways to do the procedure.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 5 / 31

Page 7: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

Answer

The task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.There are 12 ways to choose an office for John, because thereare 12 offices available.There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 8: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

Answer

The task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.There are 12 ways to choose an office for John, because thereare 12 offices available.There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 9: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

AnswerThe task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.

There are 12 ways to choose an office for John, because thereare 12 offices available.There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 10: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

AnswerThe task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.There are 12 ways to choose an office for John, because thereare 12 offices available.

There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 11: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

AnswerThe task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.There are 12 ways to choose an office for John, because thereare 12 offices available.There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 12: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(1) A new company with just 2 employees, John and Wayne,rents a floor of a building with 12 offices. How many ways arethere to assign different offices to these two employees?

AnswerThe task can be broken down into a sequence of 2 tasks:choosing an office for John, followed by choosing an office forWayne.There are 12 ways to choose an office for John, because thereare 12 offices available.There are 11 choices for the office of Wayne, because onlyJohn’s office is unavailable.

⇒ by the product rule, there are 12 · 11 = 132 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 6 / 31

Page 13: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

Answer

This task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 14: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

Answer

This task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 15: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.

According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 16: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 17: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 18: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

Answer

Each of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 19: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

AnswerEach of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 20: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product rule

(2) The seats of a lab room are to be labelled with a letter and anumber not exceeding 25. What is the largest number ofchairs that can be labeled differently?

AnswerThis task can be broken down into a sequence of 2 tasks:assign one of the 26 letter, followed by assigning one of the 25possible numbers to the seat.According to the product rule, there are 26 · 25 = 650 ways todo so.

(3) How many different bit strings of length 7 are there?

AnswerEach of the 7 bits can be chosen in 2 ways, because each bit iseither 0 or 1.

⇒ by the product rule, there are 27 = 128 ways.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 7 / 31

Page 21: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting functions

(4) How many functions are there from a set with m elements toa set with n elements?

AnswerThe procedure to define such a function can be broken downinto a sequence of m subtasks, where each subtask fixes theoutput value for an input argument.Each subtask can be done in n ways (there are n possibleoutput values)

⇒ by product rule, the number of functions is n · . . . · n︸ ︷︷ ︸m times

= nm

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 8 / 31

Page 22: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}

Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 23: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}

Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 24: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}

Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 25: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.

There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 26: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.

There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 27: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}

...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 28: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}

...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 29: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 30: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting one-to-one functions

(5) How many one-to-one functions are there from a set with melements to one with n elements?

Remark. A one-to-one function is a function that mapsdifferent elements to different values.

Answer: assume f : {a1, . . . , am} → {b1, . . . , bn}Note that we must have m ≤ n.There are n ways to pick a value forf (a1) ∈ {b1, . . . , bm}.There are n − 1 ways to pick a value forf (a2) ∈ {b1, . . . , bm} − {f (a1)}...There are n −m + 1 ways to pick the function value forf (am) ∈ {b1, . . . , bm} − {f (a1), . . . , f (am−1)}.

⇒ By product rule, there are n · (n − 1) · . . . · (n −m + 1)one-to-one functions.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 9 / 31

Page 31: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 32: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

Answer

For every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 33: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 34: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.

The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 35: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.

By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 36: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 37: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the product ruleCounting the subsets of a finite set

(6) The number of subsets of a finite set S = {a1, a2, . . . , an} is 2n.

AnswerFor every subset B of A we define the bit string b1b2 . . . bn with

bi =

{1 if ai ∈ B0 otherwise

There is a one-to-one correspondence between the subsets of Aand the bit strings of length n.The procedure to define a bit string of length n is a sequenceof n tasks, where each task chooses the value of a different bitfrom the bit string.By the product rule, there are 2n such bit strings.

⇒ there are 2n subsets of S .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 10 / 31

Page 38: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Basic counting principles2. The sum rule

Sum rule. If a procedure can be done either in one of n1 ways or inone of n2 ways, and none of the set of n1 ways is the sameas any of the n2 ways, then there are n1 + n2 ways to dothe procedure.

Generalized sum rule. Suppose that a procedure can be done in one ofn1 ways, in one of n2 ways, . . . , or in one of nm ways,where none of the set of ni ways of doing the task is thesame as any of the set of nj ways, for all pairs i and j with1 ≤ i < j ≤ m. Then the number of ways to do the task isn1 + n2 + . . . + nm.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 11 / 31

Page 39: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Basic counting principles2. The sum rule

Sum rule. If a procedure can be done either in one of n1 ways or inone of n2 ways, and none of the set of n1 ways is the sameas any of the n2 ways, then there are n1 + n2 ways to dothe procedure.

Generalized sum rule. Suppose that a procedure can be done in one ofn1 ways, in one of n2 ways, . . . , or in one of nm ways,where none of the set of ni ways of doing the task is thesame as any of the set of nj ways, for all pairs i and j with1 ≤ i < j ≤ m. Then the number of ways to do the task isn1 + n2 + . . . + nm.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 11 / 31

Page 40: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Basic counting principles2. The sum rule

Sum rule. If a procedure can be done either in one of n1 ways or inone of n2 ways, and none of the set of n1 ways is the sameas any of the n2 ways, then there are n1 + n2 ways to dothe procedure.

Generalized sum rule. Suppose that a procedure can be done in one ofn1 ways, in one of n2 ways, . . . , or in one of nm ways,where none of the set of ni ways of doing the task is thesame as any of the set of nj ways, for all pairs i and j with1 ≤ i < j ≤ m. Then the number of ways to do the task isn1 + n2 + . . . + nm.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 11 / 31

Page 41: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the sum rule

(1) Suppose a student can choose a computer project from one of3 lists. The three lists contain 9, 8, and 12 possible projectsrespectively. No project is on more than one list. How manypossible project are there to choose from?

Answer

The project can be chosen by selecting from the first list, thesecond list, or the third list.Because no project is in more than one list, we can apply thesum rule ⇒ there are 9 + 8 + 12 = 29 ways to choose a project.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 12 / 31

Page 42: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the sum rule

(1) Suppose a student can choose a computer project from one of3 lists. The three lists contain 9, 8, and 12 possible projectsrespectively. No project is on more than one list. How manypossible project are there to choose from?

Answer

The project can be chosen by selecting from the first list, thesecond list, or the third list.Because no project is in more than one list, we can apply thesum rule ⇒ there are 9 + 8 + 12 = 29 ways to choose a project.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 12 / 31

Page 43: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the sum rule

(1) Suppose a student can choose a computer project from one of3 lists. The three lists contain 9, 8, and 12 possible projectsrespectively. No project is on more than one list. How manypossible project are there to choose from?

AnswerThe project can be chosen by selecting from the first list, thesecond list, or the third list.

Because no project is in more than one list, we can apply thesum rule ⇒ there are 9 + 8 + 12 = 29 ways to choose a project.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 12 / 31

Page 44: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Applications of the sum rule

(1) Suppose a student can choose a computer project from one of3 lists. The three lists contain 9, 8, and 12 possible projectsrespectively. No project is on more than one list. How manypossible project are there to choose from?

AnswerThe project can be chosen by selecting from the first list, thesecond list, or the third list.Because no project is in more than one list, we can apply thesum rule ⇒ there are 9 + 8 + 12 = 29 ways to choose a project.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 12 / 31

Page 45: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 46: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 47: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 48: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.

By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 49: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.

To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 50: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 51: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 52: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 53: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 54: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting problems

Many complicated counting problems can not be solved using just thesum rule or just the product rule. But they can be solved using bothrules in combination.

Examples

(1) Assume a password is 6 to 8 characters long, where each characteris either an uppercase letter or a digit. Each password must containat least one digit. How many possible passwords are there?

Answer

Let P be the total number of passwords, and P6, P7 and P8 bethe number of passwords of length 6, 7, and 8, respectively.By sum rule, we have P = P6 + P7 + P8.To compute Pm for m ∈ {6, 7, 8}, we can proceed as follows:

Let Wm be the number of strings of uppercase letters anddigits of length m. By product rule, Wm = (26 + 10)m = 36m

Let Nm be the number of strings of uppercase letters of lengthm. By product rule, Nm = 26m.

Note that Pm = Wm − Nm (explain why).

⇒ P = W6−N6+W7−N7+W8−N8 = 366−266+367−267+368−268.Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 13 / 31

Page 55: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting examples

(2) In how many ways can we choose 2 books of differentlanguages among 5 books in Romanian, 9 in English, and 10in German?

Answer

R&E = 5× 9 = 45 by product ruleR&G = 5× 10 = 50 by product ruleE&G = 9× 10 = 90 by product rule

⇒ 45 + 50 + 90 = 185 ways (by sum rule).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 14 / 31

Page 56: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

More complex counting examples

(2) In how many ways can we choose 2 books of differentlanguages among 5 books in Romanian, 9 in English, and 10in German?

Answer

R&E = 5× 9 = 45 by product ruleR&G = 5× 10 = 50 by product ruleE&G = 9× 10 = 90 by product rule

⇒ 45 + 50 + 90 = 185 ways (by sum rule).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 14 / 31

Page 57: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinatorial proofs

A combinatorial proof is a proof that uses counting arguments,such as the sum rule and product rule to prove something.

The proofs illustrated in the previous examples arecombinatorial proofs.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 15 / 31

Page 58: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and combinationsDefinitions

Assumption: A is a finite set with n elements.

An r -permutation is an ordered sequence 〈a1, a2, . . . , ar 〉 of relements of A.

A permutation of A is an ordered sequence 〈a1, a2, . . . , an〉 of allelements of A.

An r -combination of A is an unordered selection {a1, a2, . . . , ar} ofr elements of A.

Example

〈3, 1, 2〉 and 〈1, 3, 2〉 are permutations of {1, 2, 3}.〈3, 1〉 and 〈1, 2〉 are 2-permutations of {1, 2, 3}.

P(n, r) := the number of r -permutations of a set with nelements.

C (n, r) := the number of r -combinations of a set with nelements. Alternative notation:

(nr

).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 16 / 31

Page 59: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and combinationsDefinitions

Assumption: A is a finite set with n elements.

An r -permutation is an ordered sequence 〈a1, a2, . . . , ar 〉 of relements of A.

A permutation of A is an ordered sequence 〈a1, a2, . . . , an〉 of allelements of A.

An r -combination of A is an unordered selection {a1, a2, . . . , ar} ofr elements of A.

Example

〈3, 1, 2〉 and 〈1, 3, 2〉 are permutations of {1, 2, 3}.〈3, 1〉 and 〈1, 2〉 are 2-permutations of {1, 2, 3}.

P(n, r) := the number of r -permutations of a set with nelements.

C (n, r) := the number of r -combinations of a set with nelements. Alternative notation:

(nr

).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 16 / 31

Page 60: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and combinationsDefinitions

Assumption: A is a finite set with n elements.

An r -permutation is an ordered sequence 〈a1, a2, . . . , ar 〉 of relements of A.

A permutation of A is an ordered sequence 〈a1, a2, . . . , an〉 of allelements of A.

An r -combination of A is an unordered selection {a1, a2, . . . , ar} ofr elements of A.

Example

〈3, 1, 2〉 and 〈1, 3, 2〉 are permutations of {1, 2, 3}.〈3, 1〉 and 〈1, 2〉 are 2-permutations of {1, 2, 3}.

P(n, r) := the number of r -permutations of a set with nelements.

C (n, r) := the number of r -combinations of a set with nelements. Alternative notation:

(nr

).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 16 / 31

Page 61: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

PermutationsWhat is the value of P(n, r)?

Theorem

P(n, r) = n · (n − 1) · . . . · (n − r + 1).

Proof

A = {a1, . . . , an}r -permutation = p1, p2, ..., pr

choice tasksp1 ∈ A p2 ∈ A− {p1} . . . pr ∈ A− {p1, . . . , pr−1}

# of choices n n − 1 . . . n − r + 1

⇒ P(n, r) = n · (n − 1) · . . . · (n − r + 1) =n!

(n − r)!

Remark. n! denotes the product 1 · 2 · . . . · (n − 1) · n.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 17 / 31

Page 62: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

PermutationsWhat is the value of P(n, r)?

Theorem

P(n, r) = n · (n − 1) · . . . · (n − r + 1).

ProofA = {a1, . . . , an}r -permutation = p1, p2, ..., pr

choice tasksp1 ∈ A p2 ∈ A− {p1} . . . pr ∈ A− {p1, . . . , pr−1}

# of choices n n − 1 . . . n − r + 1

⇒ P(n, r) = n · (n − 1) · . . . · (n − r + 1) =n!

(n − r)!

Remark. n! denotes the product 1 · 2 · . . . · (n − 1) · n.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 17 / 31

Page 63: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

PermutationsWhat is the value of P(n, r)?

Theorem

P(n, r) = n · (n − 1) · . . . · (n − r + 1).

ProofA = {a1, . . . , an}r -permutation = p1, p2, ..., pr

choice tasksp1 ∈ A p2 ∈ A− {p1} . . . pr ∈ A− {p1, . . . , pr−1}

# of choices n n − 1 . . . n − r + 1

⇒ P(n, r) = n · (n − 1) · . . . · (n − r + 1) =n!

(n − r)!

Remark. n! denotes the product 1 · 2 · . . . · (n − 1) · n.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 17 / 31

Page 64: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

PermutationsWhat is the value of P(n, r)?

Theorem

P(n, r) = n · (n − 1) · . . . · (n − r + 1).

ProofA = {a1, . . . , an}r -permutation = p1, p2, ..., pr

choice tasksp1 ∈ A p2 ∈ A− {p1} . . . pr ∈ A− {p1, . . . , pr−1}

# of choices n n − 1 . . . n − r + 1

⇒ P(n, r) = n · (n − 1) · . . . · (n − r + 1) =n!

(n − r)!

Remark. n! denotes the product 1 · 2 · . . . · (n − 1) · n.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 17 / 31

Page 65: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and CombinationsProperties

Theorem

P(n, r) = C (n, r)× P(r , r).

Combinatorial proof

An r -permutation of a set with n elements can be performedby a sequence of 2 tasks:

1 choose r elements from the set with n elements2 arrange them.

There are C (n, r) ways to choose r elements out of n ⇒ task(1) can be done in C (n, r) ways.

There are P(r , r) ways to arrange r elements ⇒ task (2) canbe done in P(r , r) ways.

⇒ by product rule, we obtain P(n, r) = C (n, r)× P(r , r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 18 / 31

Page 66: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and CombinationsProperties

Theorem

P(n, r) = C (n, r)× P(r , r).

Combinatorial proof

An r -permutation of a set with n elements can be performedby a sequence of 2 tasks:

1 choose r elements from the set with n elements2 arrange them.

There are C (n, r) ways to choose r elements out of n ⇒ task(1) can be done in C (n, r) ways.

There are P(r , r) ways to arrange r elements ⇒ task (2) canbe done in P(r , r) ways.

⇒ by product rule, we obtain P(n, r) = C (n, r)× P(r , r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 18 / 31

Page 67: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and CombinationsProperties

Theorem

P(n, r) = C (n, r)× P(r , r).

Combinatorial proof

An r -permutation of a set with n elements can be performedby a sequence of 2 tasks:

1 choose r elements from the set with n elements2 arrange them.

There are C (n, r) ways to choose r elements out of n ⇒ task(1) can be done in C (n, r) ways.

There are P(r , r) ways to arrange r elements ⇒ task (2) canbe done in P(r , r) ways.

⇒ by product rule, we obtain P(n, r) = C (n, r)× P(r , r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 18 / 31

Page 68: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and CombinationsProperties

Theorem

P(n, r) = C (n, r)× P(r , r).

Combinatorial proof

An r -permutation of a set with n elements can be performedby a sequence of 2 tasks:

1 choose r elements from the set with n elements2 arrange them.

There are C (n, r) ways to choose r elements out of n ⇒ task(1) can be done in C (n, r) ways.

There are P(r , r) ways to arrange r elements ⇒ task (2) canbe done in P(r , r) ways.

⇒ by product rule, we obtain P(n, r) = C (n, r)× P(r , r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 18 / 31

Page 69: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and CombinationsProperties

Theorem

P(n, r) = C (n, r)× P(r , r).

Combinatorial proof

An r -permutation of a set with n elements can be performedby a sequence of 2 tasks:

1 choose r elements from the set with n elements2 arrange them.

There are C (n, r) ways to choose r elements out of n ⇒ task(1) can be done in C (n, r) ways.

There are P(r , r) ways to arrange r elements ⇒ task (2) canbe done in P(r , r) ways.

⇒ by product rule, we obtain P(n, r) = C (n, r)× P(r , r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 18 / 31

Page 70: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

CombinationsCounting combinations

C (n, r) =?

We already know how to compute P(n, r), it is n!(n−r)!

We proved that P(n, r) = C (n, r)× P(r , r)

⇒ C (n, r) =P(n, r)

P(r , r)=

n!

(n − r)!· 0!

r !=

n!

r !(n − r)!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 19 / 31

Page 71: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

CombinationsCounting combinations

C (n, r) =?

We already know how to compute P(n, r), it is n!(n−r)!

We proved that P(n, r) = C (n, r)× P(r , r)

⇒ C (n, r) =P(n, r)

P(r , r)=

n!

(n − r)!· 0!

r !=

n!

r !(n − r)!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 19 / 31

Page 72: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

CombinationsCounting combinations

C (n, r) =?

We already know how to compute P(n, r), it is n!(n−r)!

We proved that P(n, r) = C (n, r)× P(r , r)

⇒ C (n, r) =P(n, r)

P(r , r)=

n!

(n − r)!· 0!

r !=

n!

r !(n − r)!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 19 / 31

Page 73: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

CombinationsCounting combinations

C (n, r) =?

We already know how to compute P(n, r), it is n!(n−r)!

We proved that P(n, r) = C (n, r)× P(r , r)

⇒ C (n, r) =P(n, r)

P(r , r)=

n!

(n − r)!· 0!

r !=

n!

r !(n − r)!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 19 / 31

Page 74: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 75: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 76: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 77: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 78: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 79: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 80: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Properties of combinations

Theorem

C (n, r) = C (n − 1, r − 1) + C (n − 1, r) for all n > r > 0.

Combinatorial proof

Let S = {a1, a2, . . . , an}. There are C (n, r) ways to choose relements from S . We distinguish 2 distinct possibilities:

1 The choice of r elements from S contains a1. Let N1 be thenumber of such choices.

2 The choice of r elements from S does not contain a1. Let N2

be the number of such choices.

By sum rule, C (n, r) = N1 + N2. But:

N1 = C (n − 1, r − 1) because we have to choose r − 1elements from {a2, . . . , an}N2 = C (n − 1, r) because we have to choose r elements from{a2, . . . , an}

⇒ C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 20 / 31

Page 81: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Quizzes

1 Give an algebraic proof, using the formulas for C (n, r), of thefact that C (n, r) = C (n − 1, r − 1) + C (n − 1, r).

2 Give a combinatorial proof of the fact thatC (n, r) = C (n, n − r).

3 How many ways are there to select a first-prize winner, asecond-prize winner, and a third-prize winner from 100different people who have entered a contest?

4 In how many ways can n people stand to form a ring?

5 How many permutations of the letters ABCDEFGH containthe string ABC?

6 How many bit strings of length n contain exactly r 1s?

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 21 / 31

Page 82: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Generalized permutations and combinationsPermutations with repetition

In many counting problems, we want to use elementsrepeatedly.Permutations and combinations assume that every itemappears only once.An r -permutation with repetition of a set of n elements is anarrangement of r elements from that set, where elements mayoccur more than once.

Example

How many strings of length n can be formed with the lowercaseand uppercase letters of the English alphabet?Answer: |AlphabetEnglish| = 52 ⇒ 52n strings (by product rule)

Theorem

The number of r -permutations of a set of n elements withrepetition is nr .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 22 / 31

Page 83: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Generalized permutations and combinationsPermutations with repetition

In many counting problems, we want to use elementsrepeatedly.

Permutations and combinations assume that every itemappears only once.An r -permutation with repetition of a set of n elements is anarrangement of r elements from that set, where elements mayoccur more than once.

Example

How many strings of length n can be formed with the lowercaseand uppercase letters of the English alphabet?Answer: |AlphabetEnglish| = 52 ⇒ 52n strings (by product rule)

Theorem

The number of r -permutations of a set of n elements withrepetition is nr .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 22 / 31

Page 84: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Generalized permutations and combinationsPermutations with repetition

In many counting problems, we want to use elementsrepeatedly.Permutations and combinations assume that every itemappears only once.

An r -permutation with repetition of a set of n elements is anarrangement of r elements from that set, where elements mayoccur more than once.

Example

How many strings of length n can be formed with the lowercaseand uppercase letters of the English alphabet?Answer: |AlphabetEnglish| = 52 ⇒ 52n strings (by product rule)

Theorem

The number of r -permutations of a set of n elements withrepetition is nr .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 22 / 31

Page 85: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Generalized permutations and combinationsPermutations with repetition

In many counting problems, we want to use elementsrepeatedly.Permutations and combinations assume that every itemappears only once.An r -permutation with repetition of a set of n elements is anarrangement of r elements from that set, where elements mayoccur more than once.

Example

How many strings of length n can be formed with the lowercaseand uppercase letters of the English alphabet?Answer: |AlphabetEnglish| = 52 ⇒ 52n strings (by product rule)

Theorem

The number of r -permutations of a set of n elements withrepetition is nr .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 22 / 31

Page 86: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Generalized permutations and combinationsPermutations with repetition

In many counting problems, we want to use elementsrepeatedly.Permutations and combinations assume that every itemappears only once.An r -permutation with repetition of a set of n elements is anarrangement of r elements from that set, where elements mayoccur more than once.

Example

How many strings of length n can be formed with the lowercaseand uppercase letters of the English alphabet?Answer: |AlphabetEnglish| = 52 ⇒ 52n strings (by product rule)

Theorem

The number of r -permutations of a set of n elements withrepetition is nr .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 22 / 31

Page 87: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetition

An r -combination with repetition of a set of n elements is achoice of r elements from a bag of elements of n kinds, wherewe can choose the same kind of element any number of times.

Q: How many r -combinations with repetition of a set of nelements are there?

Example

How many ways are there to select 5 bills from a cash boxcontaining bills of $1, $2, $5, $10, $20, $50. Assume that: theorder in which the bills are chosen does not matter; the bills areindistinguishable; there are at least 5 bills of each type.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 23 / 31

Page 88: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetitionExample – continued

Five not necessarily distinct bills = a 5-combination with repetition fromthe set {$1, $2, $5, $10, $20, $50} of bill kinds = a placement of five * inthe slots of the cash box depicted below:

The number of * in a slot represents the number of bills taken fromthat place.

⇒ The number of 5-combinations with repetition of a set with 6

elements = the number of ways to place 5 stars in 6 slots.

$1 $2 $5 $10 $20 $50cash box with 6 types of bills

||∗∗|||∗∗∗∗∗ ∗∗∗

∗|| ∗ |∗|∗∗|∗ ∗ ∗ ∗∗

· · ·

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 24 / 31

Page 89: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetition

Note that

Every placement of 5 stars in 6 possible slots is uniquelydescribed by a string of 5 stars and 5 red bars.

In general, the number of r -combinations with repetition of aset with n elements = the number of strings with r stars andn − 1 red bars.

Q: In how many ways can we arrange n − 1 bars and r stars ?

A: The sequence has length n + r − 1⇒ there are n + r − 1 positions in the sequence⇒ we must choose r positions out of n + r − 1 to be filled with

stars; the others will be filled with red bars.

There are C (n + r − 1, r) such choices.

Theorem

The number of r -combinations with repetition of n elements isC (r + n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 25 / 31

Page 90: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetition

Note that

Every placement of 5 stars in 6 possible slots is uniquelydescribed by a string of 5 stars and 5 red bars.

In general, the number of r -combinations with repetition of aset with n elements = the number of strings with r stars andn − 1 red bars.

Q: In how many ways can we arrange n − 1 bars and r stars ?A: The sequence has length n + r − 1

⇒ there are n + r − 1 positions in the sequence⇒ we must choose r positions out of n + r − 1 to be filled with

stars; the others will be filled with red bars.

There are C (n + r − 1, r) such choices.

Theorem

The number of r -combinations with repetition of n elements isC (r + n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 25 / 31

Page 91: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetition

Note that

Every placement of 5 stars in 6 possible slots is uniquelydescribed by a string of 5 stars and 5 red bars.

In general, the number of r -combinations with repetition of aset with n elements = the number of strings with r stars andn − 1 red bars.

Q: In how many ways can we arrange n − 1 bars and r stars ?A: The sequence has length n + r − 1

⇒ there are n + r − 1 positions in the sequence⇒ we must choose r positions out of n + r − 1 to be filled with

stars; the others will be filled with red bars.

There are C (n + r − 1, r) such choices.

Theorem

The number of r -combinations with repetition of n elements isC (r + n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 25 / 31

Page 92: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Combinations with repetition

Note that

Every placement of 5 stars in 6 possible slots is uniquelydescribed by a string of 5 stars and 5 red bars.

In general, the number of r -combinations with repetition of aset with n elements = the number of strings with r stars andn − 1 red bars.

Q: In how many ways can we arrange n − 1 bars and r stars ?A: The sequence has length n + r − 1

⇒ there are n + r − 1 positions in the sequence⇒ we must choose r positions out of n + r − 1 to be filled with

stars; the others will be filled with red bars.

There are C (n + r − 1, r) such choices.

Theorem

The number of r -combinations with repetition of n elements isC (r + n − 1, r).

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 25 / 31

Page 93: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations and combinationsSummary

Type Repetition Formulaallowed?

r -permutations No P(n, r) =n!

(n − r)!

r -combinations No C (n, r) =n!

r !(n − r)!r -permutations Yes nr

with repetition

r -combinations Yes C (n + r − 1, r) =(n + r − 1)!

r !(n − 1)!with repetition

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 26 / 31

Page 94: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutation with indistinguishable objects

Problem

How many strings can be made by reordering the string SUCCESS?

SUCCESS contains 3 Ss, 2 Cs, 1U, 1 E.

placements of 3 Ss among 7 places: C (7, 3) ⇒ 4 places left.

placements of 2 Cs among 4 places: C (4, 2) ⇒ 2 places left.

placements of 1 U among 2 places: C (2, 1) ⇒ 1 place left.

placements of 1 E among 1 place: C (1, 1).

⇒ by product rule, the number is

C (7, 3)× C (4, 2)× C (2, 1)× C (1, 1) =7!

3!2!1!1!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 27 / 31

Page 95: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutation with indistinguishable objects

Problem

How many strings can be made by reordering the string SUCCESS?

SUCCESS contains 3 Ss, 2 Cs, 1U, 1 E.

placements of 3 Ss among 7 places: C (7, 3) ⇒ 4 places left.

placements of 2 Cs among 4 places: C (4, 2) ⇒ 2 places left.

placements of 1 U among 2 places: C (2, 1) ⇒ 1 place left.

placements of 1 E among 1 place: C (1, 1).

⇒ by product rule, the number is

C (7, 3)× C (4, 2)× C (2, 1)× C (1, 1) =7!

3!2!1!1!

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 27 / 31

Page 96: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Permutations with indistinguishable objects

Theorem

The number of different permutations of n objects, where there are

B n1 indistinguishable elements of type 1

B n2 indistinguishable elements of type 2

. . .

B nk indistinguishable elements of type nk

isn!

n1!n2! · · · nk !.

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 28 / 31

Page 97: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial and multinomial numbers

The binomial numbers are the coefficients cn,k in the formula

(x + y)n =n∑

k=0

cn,k · xn−kyk

The multinomial numbers are the coefficients cn,k1,...,kr in theformula

(x1 + . . . + xr )n =n∑

k1+...+kr=n

cn,k1,...,kr · xk11 xk2

2 . . . xkrr

Example

(x + y)3 = 1 · x3 + 3 · x2y + 3 · x y2 + 1 · y3

(x1 + x2 + x3)2 = 1 · x21 + 1 · x2

2 + 1 · x23 +

2 · x1x2 + 2 · x1x3 + 2 · x2x3

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 29 / 31

Page 98: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersHow to compute them?

(x1 + . . . + xr )n =

n∑k1+...+kr=n

n!

k1! . . . kr !· xk1

1 xk22 . . . xkrr

Combinatorial proof

(x1 + . . . + xr )n =

n parenthesized expressions︷ ︸︸ ︷(x1 + . . . + xr ) · . . . · (x1 + . . . + xr )

In how many ways can we produce the monomial xk11 · . . . · xkrr ?

B Choose k1 parentheses from where x1 originates ⇒(nk1

)choices.

B Choose k2 parentheses from where x2 originates ⇒(n−k1

k2

)choices.

. . .

B Choose kr parentheses from where xr originates ⇒(n−∑r−1

i=1 kikr

)choices.

⇒ by the product rule, the number of occurrences of xk11 · . . . · xkrr in the

right hand side is(nk1

)(n−k1

k2

)· . . . ·

(n−∑r−1i=1 kikr

)=

n!

k1! . . . kr !

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 30 / 31

Page 99: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersHow to compute them?

(x1 + . . . + xr )n =

n∑k1+...+kr=n

n!

k1! . . . kr !· xk1

1 xk22 . . . xkrr

Combinatorial proof

(x1 + . . . + xr )n =

n parenthesized expressions︷ ︸︸ ︷(x1 + . . . + xr ) · . . . · (x1 + . . . + xr )

In how many ways can we produce the monomial xk11 · . . . · xkrr ?

B Choose k1 parentheses from where x1 originates ⇒(nk1

)choices.

B Choose k2 parentheses from where x2 originates ⇒(n−k1

k2

)choices.

. . .

B Choose kr parentheses from where xr originates ⇒(n−∑r−1

i=1 kikr

)choices.

⇒ by the product rule, the number of occurrences of xk11 · . . . · xkrr in the

right hand side is(nk1

)(n−k1

k2

)· . . . ·

(n−∑r−1i=1 kikr

)=

n!

k1! . . . kr !

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 30 / 31

Page 100: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersHow to compute them?

(x1 + . . . + xr )n =

n∑k1+...+kr=n

n!

k1! . . . kr !· xk1

1 xk22 . . . xkrr

Combinatorial proof

(x1 + . . . + xr )n =

n parenthesized expressions︷ ︸︸ ︷(x1 + . . . + xr ) · . . . · (x1 + . . . + xr )

In how many ways can we produce the monomial xk11 · . . . · xkrr ?

B Choose k1 parentheses from where x1 originates ⇒(nk1

)choices.

B Choose k2 parentheses from where x2 originates ⇒(n−k1

k2

)choices.

. . .

B Choose kr parentheses from where xr originates ⇒(n−∑r−1

i=1 kikr

)choices.

⇒ by the product rule, the number of occurrences of xk11 · . . . · xkrr in the

right hand side is(nk1

)(n−k1

k2

)· . . . ·

(n−∑r−1i=1 kikr

)=

n!

k1! . . . kr !

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 30 / 31

Page 101: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersHow to compute them?

(x1 + . . . + xr )n =

n∑k1+...+kr=n

n!

k1! . . . kr !· xk1

1 xk22 . . . xkrr

Combinatorial proof

(x1 + . . . + xr )n =

n parenthesized expressions︷ ︸︸ ︷(x1 + . . . + xr ) · . . . · (x1 + . . . + xr )

In how many ways can we produce the monomial xk11 · . . . · xkrr ?

B Choose k1 parentheses from where x1 originates ⇒(nk1

)choices.

B Choose k2 parentheses from where x2 originates ⇒(n−k1

k2

)choices.

. . .

B Choose kr parentheses from where xr originates ⇒(n−∑r−1

i=1 kikr

)choices.

⇒ by the product rule, the number of occurrences of xk11 · . . . · xkrr in the

right hand side is(nk1

)(n−k1

k2

)· . . . ·

(n−∑r−1i=1 kikr

)=

n!

k1! . . . kr !

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 30 / 31

Page 102: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersHow to compute them?

(x1 + . . . + xr )n =

n∑k1+...+kr=n

n!

k1! . . . kr !· xk1

1 xk22 . . . xkrr

Combinatorial proof

(x1 + . . . + xr )n =

n parenthesized expressions︷ ︸︸ ︷(x1 + . . . + xr ) · . . . · (x1 + . . . + xr )

In how many ways can we produce the monomial xk11 · . . . · xkrr ?

B Choose k1 parentheses from where x1 originates ⇒(nk1

)choices.

B Choose k2 parentheses from where x2 originates ⇒(n−k1

k2

)choices.

. . .

B Choose kr parentheses from where xr originates ⇒(n−∑r−1

i=1 kikr

)choices.

⇒ by the product rule, the number of occurrences of xk11 · . . . · xkrr in the

right hand side is(nk1

)(n−k1

k2

)· . . . ·

(n−∑r−1i=1 kikr

)=

n!

k1! . . . kr !Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 30 / 31

Page 103: Graph Theory and Combinatorics - staff.fmi.uvt.roisabela.dramnesc/GTC/Lecture1_GTC.pdf · Graph Theory and Combinatorics Lecture 1: Introduction. Counting Principles. Permutations

Binomial numbers and multinomial numbersConclusions

For the formula n!k1!...kr ! with k1 + . . . + kr = n we often use

the notation( nk1,...,kr

).

The binomial formula is

(x + y)n =n∑

k=0

(n

k

)xn−kyk

The multinomial formulas

(x1 + . . . + xr )n =∑

k1+...+kr=n

(n

k1, . . . , kr

)xk1

1 · . . . · xkrr

Remark.(nk

)=( nk,n−k

)and

(x1 + x2)n =n∑

k=0

(n

k

)xk1 x

n−k2 =

∑k1+k2=n

(n

k1, k2

)xk1

1 xk22 .

Isabela Dramnesc UVT Graph Theory and Combinatorics – Lecture 1 31 / 31