Professional Documents
Culture Documents
FACULTY OF ENGINEERING
ELECTRICAL & ELECTRONICS ENGINEERING DEPT.
7. Basic of Counting
Instructor:
Assist. Prof. Dr. Mohammed ALKRUNZ
Electrical & Electronics Engineering Dept.
Basic of Counting,,,
The study of the number of ways to put things together into various
combinations.
Let “m” be the number of ways to do task 1, and “n” be the number of ways
to do task 2.
Dr. M. Alkrunz
December 5, 2022 2
EEE247: Discrete Mathematics
Basic of Counting,,,
The Sum Rule:
The task “do either task 1 or task 2, but not both” can be done in (𝒎 + 𝒏)
ways.
The Product Rule:
The task “do both task 1 and task 2” can be done in (𝒎 × 𝒏) ways.
If “A” is the set of ways to do task 1, and “B” is the set of ways to do task 2,
and if “A” and “B” are disjoint, then:
Dr. M. Alkrunz
December 5, 2022 3
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
A student can choose a project from one of three lists. The three lists contains
23, 15, and 19 possible projects respectively. How many possible projects are
there to choose from?!!
Projects are all distinct.
Hence, total = 23 + 15 + 19 = 57 projects.
How many integers between 1 and 100 (including 100) are even or end with 5?
Let “A” be the set of even integer between 1 and 100.
Then, 𝐴 = 2, 4, 6, … … , 100 and 𝑨 = 𝟓𝟎 elements.
Let “B” be the set of integers end with 5.
Then, 𝐵 = 5, 15, 25, … … , 95 and 𝑩 = 𝟏𝟎 elements.
So, by addition principle: 𝑨 ∪ 𝑩 = 𝑨 + 𝑩 = 𝟓𝟎 + 𝟏𝟎 = 𝟔𝟎
Dr. M. Alkrunz
December 5, 2022 4
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
How many different bit strings of length 7 are there?
Bits: either zero or one.
Each of the seven bits can be chosen in two ways.
So, there are a total of 𝟐𝟕 = 𝟏𝟐𝟖 different bit strings.
Examples:
How many bit strings of length 3 either start with 1 or end with 00?
Let “A” is the set of bit strings start with 1. Then: 𝑨 = 𝟒
Let “B” is the set of bit strings end with 00. Then: 𝑩 = 𝟐
0 0 0
𝑨∪𝑩 = 𝑨 + 𝑩 − 𝑨∩𝑩 = 𝟒+𝟐−𝟏=𝟓
0 0 1
0 1 0
𝑨 𝑩 𝑨∩𝑩 0 1 1
1 0 0 1 0 0 1 0 0
2 2 2 1 0 1
1 1 0
4 2 1
1 1 1
Dr. M. Alkrunz
December 5, 2022 6
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
How many bit strings of length 4 or less?
A total of: 𝟐𝟒 + 𝟐𝟑 + 𝟐𝟐 + 𝟐𝟏 = 𝟏𝟔 + 𝟖 + 𝟒 + 𝟐 = 𝟑𝟎
Find the number of three letters initials where none of the letters is
repeated?
A total of: 𝟐𝟔 × 𝟐𝟓 × 𝟐𝟒 = 𝟏𝟓, 𝟔𝟎𝟎
26 25 24
Find the number of three letters initials where the letters could be
repeated?
A total of: 𝟐𝟔 × 𝟐𝟔 × 𝟐𝟔 = 𝟏𝟕, 𝟓𝟕𝟔
26 26 26
Dr. M. Alkrunz
December 5, 2022 7
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
Count the set “S” of 3 digit numbers which begins or end with an even digit?
Even numbers are: 0, 2, 4, 6, 8
Assume “A” is the set of numbers begin with an even digit.
Assume “B” is the set of numbers end with an even digit.
Remember that the number can not begin with zero.
𝑨 𝑩 𝑨∩𝑩
4 10 10 9 10 5 4 10 5
400 450 200
Dr. M. Alkrunz
December 5, 2022 8
EEE247: Discrete Mathematics
Basic of Counting,,,
Pigeonhole Principle
X X X X XXX X XX X
X X X X X XXX XX
X X XX X X X XX X X
9 places 9 places 9 places
10 pigeons 10 pigeons 12 pigeons
Dr. M. Alkrunz
December 5, 2022 9
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
There are 101 possible numeric grades (0% - 100%) rounded to the nearest
integer. Also there are “> 𝟏𝟎𝟏” students in this class.
Therefore, there must be at least one (rounded) grade that will be shared
by at least 2 students.
Dr. M. Alkrunz
December 5, 2022 10
EEE247: Discrete Mathematics
Basic of Counting,,,
Examples:
We have 5 possible grades: A, B, C, D, F. How many students do we need to
be sure that at least 6 students get the same grades?
If we have 25 students, then we can have 5 A’s, 5 B’s , ….. etc.
Then, if we have 26 students, we need to add a student to a grade which
then has 6 students.
𝒏!
𝑷 𝒏, 𝒓 = 𝒏 𝒏 − 𝟏 𝒏 − 𝟐 … … … 𝒏 − 𝒓 + 𝟏 =
𝒏−𝒓 !
Dr. M. Alkrunz
December 5, 2022 12
EEE247: Discrete Mathematics
Urn Models
We are given a set of “n” objects in an urn.
We are going to pick (select) “r” objects from the urn in sequence.
How many different possible sequence for “r” objects are there?!!!
Dr. M. Alkrunz
December 5, 2022 13
EEE247: Discrete Mathematics
Urn Models
Two common counting problem associated with the selection without
replacement of “r” objects from the urn with “n” objects.
If 𝑟 ≤ 𝑛, then the arrangement using “r” of the “n” distinct objects is called
r-permutation.
𝒏!
𝑷 𝒏, 𝒓 = 𝒏 𝒏 − 𝟏 𝒏 − 𝟐 … … … 𝒏 − 𝒓 + 𝟏 =
𝒏−𝒓 !
Dr. M. Alkrunz
December 5, 2022 15
EEE247: Discrete Mathematics
Permutation
Example:
If a bomb planted in your city, and it is your job to disable it by cutting wires
of the trigger device. There are 10 wires to the bomb. If you cut exactly the
right 3 wires, in exactly the right order, you will disable the bomb. Otherwise,
it will explode!!
If the wires all look the same, what are your chances of survivals?!!
𝑛! 10! 10!
𝑃 10, 3 = = = = 720
𝑛−𝑟 ! 10 − 3 ! 7!
1
Chance of survival is: ∗ 100% = 0.13%
720
Dr. M. Alkrunz
December 5, 2022 16
EEE247: Discrete Mathematics
Permutation
Example:
How many different 3-digits numbers can be formed using the digits 5, 6, 7, 8,
9 without repetition?!!
𝑛! 5! 5!
𝑃 5, 3 = = = = 60
𝑛−𝑟 ! 5 − 3 ! 2!
5 4 3
Dr. M. Alkrunz
December 5, 2022 17
EEE247: Discrete Mathematics
Combinations
Combination:
Now, we turn our attention to counting unordered selections of objects.
In order the idea to be clear, consider the following example:
Example:
How many different committees of the 3 students can be formed from a
group of 4 students?!!
To answer this question, we need only to find the number of subsets with
three elements from the set containing the four students.
𝑇 ⊆ 𝑆, 𝑇 = 3 and 𝑆 = 4
Choosing 3 students is the same as choosing one student to leave out the
group. Thus, we have four such subsets.
Dr. M. Alkrunz
December 5, 2022 18
EEE247: Discrete Mathematics
Combinations
Example: (Continue)
This means that there are four ways to choose the three students for the
committee, where the order in which these students are chosen does not
matter.
Dr. M. Alkrunz
December 5, 2022 19
EEE247: Discrete Mathematics
Combinations
The number of r-combinations of a set with n-elements with 0 ≤ 𝑟 ≤ 𝑛 is:
𝑷 𝒏, 𝒓 𝒏!
𝑪 𝒏, 𝒓 = =
𝑷 𝒓, 𝒓 𝒓! 𝒏 − 𝒓 !
Dr. M. Alkrunz
December 5, 2022 20
EEE247: Discrete Mathematics
Combinations
Example:
How many distinct 7-card hands can be drown from a standard 52-cards?
𝑃 52, 7 52 51 (50)(49)(48)(47)(46)
𝐶 52, 7 = = = 133,784,560
𝑃 7, 7 (7)(6)(5)(4)(3)(2)(1)
Or
52!
𝐶 52, 7 = = 133,784,560
7! 45!
Dr. M. Alkrunz
December 5, 2022 21
EEE247: Discrete Mathematics
Combinations
Example:
How many bit strings of length 4 has exactly two ones or two zeros?
4!
𝐶 4, 2 = =6
2! 2!
Example:
How many bit strings of length 10 contains 4 ones?
10!
𝐶 10, 4 = = 210
4! 6!
Dr. M. Alkrunz
December 5, 2022 22
EEE247: Discrete Mathematics
Combinations
Example:
We need to form a committee of 7 people, 3 from Math, and 4 from Physics.
There are 9 Math candidates, and 11 Physics.
Two separate problems that need to be combined using two product rule.
9!
𝐶 9, 3 = = 84
3! 6!
11!
𝐶 11, 4 = = 330
4! 7!
𝑻𝒐𝒕𝒂𝒍 = 𝑪 𝟗, 𝟑 × 𝑪 𝟏𝟏, 𝟒 = 𝟖𝟒 × 𝟑𝟑𝟎 = 𝟐𝟕, 𝟕𝟐𝟎
Dr. M. Alkrunz
December 5, 2022 23
EEE247: Discrete Mathematics
Combinations
Example:
Suppose you flip a fair coin “n” times. How many different ways can you get:
No heads:
𝑛!
𝐶 𝑛, 0 = = 1 [The case when all of them no heads]
𝑛! 0!
𝐶 𝑛, 1
𝐶 𝑛, 2
𝐶 𝑛, 𝑟
Dr. M. Alkrunz
December 5, 2022 24
EEE247: Discrete Mathematics
Combinations
Example: (Continue)
Dr. M. Alkrunz
December 5, 2022 25
EEE247: Discrete Mathematics
Binomial Coefficients
We will now study some properties of the binomial coefficients.
𝑛
𝑛
𝑛 𝑛−𝑗 𝑗 𝑛 𝑛 𝑛 𝑛−1
𝑥+𝑦 = 𝑗 𝑥 𝑦 = 𝑥 + 𝑥 𝑦+ . . . . . . . . . .
0 1
𝑗=0
Where: 𝑛, 𝑗 ≥ 0 and 𝑛 ≥ 𝑗
𝑛
𝑗 is considered as a different notation for 𝐶(𝑛, 𝑗)
Dr. M. Alkrunz
December 5, 2022 26
EEE247: Discrete Mathematics
Binomial Coefficients
Example:
What is the coefficient of 𝒙𝟐 𝒚 in the expression of (𝒙 + 𝒚)𝟑 ?!!
3!
𝐶 3, 2 = 𝐶 3,1 = =3
2! 1!
Example:
What is the coefficient of 𝒙𝟏𝟐 𝒚𝟏𝟑 in the expression of (𝒙 + 𝒚)𝟐𝟓 ?!!
25!
𝐶 25, 12 = 𝐶 25,13 = = 5,200,300
12! 13!
Dr. M. Alkrunz
December 5, 2022 27
EEE247: Discrete Mathematics
Binomial Coefficients
Example:
What is the coefficient of 𝒙𝟏𝟐 𝒚𝟏𝟑 in the expression of (𝟐𝒙 − 𝟑𝒚)𝟐𝟓 ?!!
Dr. M. Alkrunz
December 5, 2022 28
EEE247: Discrete Mathematics
Binomial Coefficients
Special Case:
𝒏
𝒏
𝟐𝒏 = 𝒋
𝒋=𝟎
Proof:
We know that:
𝑛
𝑛
(𝑥 + 𝑦)𝑛 = 𝑗 𝑥 𝑛−𝑗 𝑦 𝑗
𝑗=0
Now set: 𝑥 = 1 and 𝑦 = 1, then:
𝑛 𝑛
𝑛 𝑛
2𝑛 𝑛−𝑗 𝑗
= 𝑗 (1) (1) = 𝑗
𝑗=0 𝑗=0
Dr. M. Alkrunz
December 5, 2022 29
EEE247: Discrete Mathematics
Binomial Coefficients
Some Other Special Cases:
𝒏
𝒏
(−𝟏)𝒋 𝒋 = 𝟎 Set: 𝑥 = 1 and 𝑦 = −1
𝒋=𝟎
𝒏
𝒏
(𝟐)𝒋 𝒋 = 𝟑𝒏 Set: 𝑥 = 1 and 𝑦 = 2
𝒋=𝟎
Dr. M. Alkrunz
December 5, 2022 30
EEE247: Discrete Mathematics
Binomial Coefficients
Pascal’s Identity: (Pascal’s Triangle)
𝒏+𝟏 𝒏 𝒏
= 𝒋−𝟏 + 𝒋
𝒋
where: 𝑛, 𝑗 ≥ 0 and 𝑛 ≥ 𝑗
Application:
(𝑥 + 𝑦)2 = 𝑥 2 + 2𝑥𝑦 + 𝑦 2 1 2 1
(𝑥 + 𝑦)3 = 𝑥 3 + 3𝑥 2 𝑦 + 3𝑥𝑦 2 + 𝑦 3 1 3 3 1
(𝑥 + 𝑦)4 = 𝑥 4 + 4𝑥 3 𝑦 + 6𝑥 2 𝑦 2 + 4𝑥𝑦 3 + 𝑦 4 1 4 6 4 1
Dr. M. Alkrunz
December 5, 2022 31
EEE247: Discrete Mathematics
Binomial Coefficients
Pascal’s Identity: (Pascal’s Triangle)
As general:
(𝑥 + 𝑦)2 1 2 1
(𝑥 + 𝑦)3 1 3 3 1
(𝑥 + 𝑦)4 1 4 6 4 1
(𝑥 + 𝑦)5 1 5 10 10 5 1
(𝑥 + 𝑦)6 1 6 15 20 15 6 1
(𝑥 + 𝑦)7 1 7 21 35 35 21 7 1
……. ……….
Dr. M. Alkrunz
December 5, 2022 32
EEE247: Discrete Mathematics
*Questions
Dr. M. Alkrunz
December 5, 2022 33
EEE247: Discrete Mathematics
*Thanks
Dr. M. Alkrunz
December 5, 2022 34
EEE247: Discrete Mathematics