Professional Documents
Culture Documents
Counting
Discrete Structures for Computing on August 31, 2021
Contents
Introduction
Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
1 Introduction
Contents
Counting Techniques
Pigeonhole Principle
Permutations &
3 Pigeonhole Principle Combinations
6.2
Counting
Course outcomes
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Course learning outcomes
Contents
L.O.2 Represent and model practical problems with discrete structures
L.O.2.1 – Logically describe some problems arising in Computing Introduction
Permutations &
L.O.3 Understanding of basic probability and random variables Combinations
6.3
Counting
Introduction
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
Introduction
match?
Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
6.4
Counting
Applications of Combinatorics
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
• Number theory
• Probability Contents
• Statistics Introduction
Counting Techniques
• Computer science
Pigeonhole Principle
• Game theory Permutations &
Combinations
• Information theory
• ...
6.5
Counting
Problems
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Counting Techniques
• Number of possible outcomes in experiments Pigeonhole Principle
• Number of operations used by an algorithm Permutations &
Combinations
6.6
Counting
Product Rule
Huynh Tuong Nguyen,
Example Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
There are 32 routers in a computer center. Each router has 24
ports. How many different ports in the center?
Solution
There are two tasks to choose a port:
Contents
1 picking a router
Introduction
2 picking a port on this router Counting Techniques
Because there are 32 ways to choose the router and 24 ways to Pigeonhole Principle
Permutations &
choose the port no matter which router has been selected, the Combinations
Example (1)
Two new students arrive at the dorm and there are 12 rooms
available. How many ways are there to assign different rooms to
two students? Contents
Introduction
Counting Techniques
Example (2) Pigeonhole Principle
Permutations &
How many different bit strings of length seven are there? Combinations
Example (3)
How many one-to-one functions are there from a set with m
elements to one with n elements?
6.8
Counting
Sum Rule
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
A student can choose a project from one of three fields:
Information system (32 projects), Software Engineering (12
projects) and Computer Science (15 projects). How many ways are Contents
Pigeonhole Principle
Permutations &
Definition (Sum Rule (Luật cộng)) Combinations
6.9
Counting
Using Both Rules
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Example Trang
Counting Techniques
Permutations &
Let V equal to the number of different variable names. Combinations
Example
How many bit strings of length eight either start with a 1 bit or
end with the two bits 00?
Contents
Introduction
Pigeonhole Principle
• Bit string of length eight that begins with a 1 is 2 = 128
7
Permutations &
ways Combinations
6.11
Counting
Inclusion-Exclusion
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Contents
Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
6.12
Counting
Inclusion-Exclusion
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
|A ∪ B ∪ C| =???
Contents
Introduction
Counting Techniques
Pigeonhole Principle
Example
Permutations &
Combinations
In a certain survey of a group of students, 87 students indicated
they liked Arsenal, 91 indicated that they liked Chelsea and 91
indicated that they liked MU. Of the students surveyed, 9 liked
only Arsenal, 10 liked only Chelsea, 12 liked only MU and 40 liked
all three clubs. How many of the student surveyed liked both MU
and Chelsea but not Arsenal?
6.13
Counting
Pigeonhole Principle
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Contents
Introduction
Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
6.14
Counting
Examples
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example (1)
Among any group of 367 people, there must be at least two with
the same birthday. Contents
Introduction
Because there are only 366 possible birthdays. Counting Techniques
Pigeonhole Principle
Example (2) Permutations &
Combinations
In any group of 27 English words, there must be at least two that
begin with the same letter.
Because there are 26 letters in the English alphabet.
6.15
Counting
Exercise
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
Prove that if seven distinct numbers are selected from
{1, 2, . . . , 11}, then some two of these numbers sum to 12.
Contents
Solution
Introduction
Pigeonhole Principle
2 Pigeonholes: corresponding to six sets, {1, 11}, {2, 10},
Permutations &
{3, 9}, {4, 8}, {5, 7}, {6} Combinations
6.16
Counting
Examples – Permutations
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
How many ways can we arrange three students to stand in line for Trang
a picture?
Contents
Introduction
Counting Techniques
Pigeonhole Principle
Number of choices: 6 = 3! Permutations &
Combinations
6.17
Counting
Permutations
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Definition
A permutation (hoán vị) of a set of distinct objects is an ordered
arrangement of these objects.
An ordered arrangement of r elements of a set is called an
r-permutation (hoán vị chập r). Contents
Introduction
n!
P (n, r) = Counting Techniques
(n − r)! Pigeonhole Principle
Permutations &
Combinations
Example
How many ways are there to select a first-prize winner, a
second-prize winner, and a third-prize winner from 100 different
people who have entered a contest?
6.18
Counting
Examples – Combinations
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Contents
Introduction
Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
Number of choices: 6
6.19
Counting
Combinations
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Definition (Combinations)
An r-combination (tổ hợp chập r) of elements of a set is an
unordered selection of r elements from the set. Thus, an
r-combination is simply a subset of the set with r elements.
Contents
n n!
C(n, r) = = Introduction
r r!(n − r)! Counting Techniques
Pigeonhole Principle
Permutations &
Combinations
Example
How many ways are there to select eleven players from a
22-member football team to start up?
22!
C(22, 11) = = 705432
11!11!
6.20
Counting
Exercises – Permutations with Repetition
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
orders can the salesman use when visiting these cities? Introduction
Counting Techniques
2 Suppose that there are 9 faculty members in CS department Pigeonhole Principle
and 11 in CE department. How many ways are there to select Permutations &
Combinations
a defend committee if the committee is to consist of three
faculty members from the CS and four from the CE
department?
6.21
Counting
Permutations with Repetition
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Theorem
The number of r-permutations of a set of n objects with
Contents
repetition allowed is nr .
Introduction
Counting Techniques
Example Pigeonhole Principle
How many strings of length r can be formed from the English Permutations &
Combinations
alphabet?
By product rule, we see that there are 26r strings of length r.
6.22
Counting
Example
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Introduction
Counting Techniques
CCC CEM
Pigeonhole Principle
CCE EEE
Permutations &
CCM EEM Combinations
CEE EMM
CMM MMM
6.23
Counting
Example
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Permutations &
Combinations
6.24
Counting
Combinations with Repetition
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Theorem
There are C(n + r − 1, r) r-combinations from a set with n
elements when repetition of elements is allowed. Contents
Introduction
Counting Techniques
Example
Pigeonhole Principle
How many solutions does the equation Permutations &
Combinations
x1 + x2 + x3 = 11
6.25
Counting
Examples
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Introduction
Counting Techniques
Pigeonhole Principle
6.26
Counting
Permutations with Indistinguishable Objects
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Theorem
The number of different permutations of n objects, where there
are n1 indistinguishable objects of type 1, n2 indistinguishable Contents
objects of type 2, . . . , and nk indistinguishable objects of type k, is Introduction
Counting Techniques
n!
Pigeonhole Principle
n1 !n2 ! · · · nk ! Permutations &
Combinations
Example
How many permutations are there of MISSISSIPPI?
6.27