You are on page 1of 34

ISTANBUL AYDIN UNIVERSITY

FACULTY OF ENGINEERING
ELECTRICAL & ELECTRONICS ENGINEERING DEPT.

EEE247: DISCRETE MATHEMATICS

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.

 Example: In a contest entered by 100 people. How many different top-10


outcomes could be selected?!!

 Example: If a password is 6 – 8 letters and/or digits. How many passwords


could be there?!!!

Sum & Product Rules:

 Let “m” be the number of ways to do task 1, and “n” be the number of ways
to do task 2.

 Then, we have the following rules:

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.

Set Theoretic Version:

 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:

 The ways to do either task 1 or 2 are 𝐴 ∪ 𝐵 and 𝑨 ∪ 𝑩 = 𝑨 + 𝑩

 The ways to do both task 1 and 2 are 𝐴 × 𝐵 and 𝑨 × 𝑩 = 𝑨 . 𝑩

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.

 A license contains a sequence of three letters followed by three digits. How


many different license plates are available?
 We have 26 letters in English (A to Z) and 10 digits (0 to 9).
 So, there are a total of: 26 × 26 × 26 × 10 × 10 × 10 = 17,576,000
possible license plates.

Letter Letter Letter Digit Digit Digit


26 26 26 10 10 10
Dr. M. Alkrunz
December 5, 2022 5
EEE247: Discrete Mathematics
Basic of Counting,,,
Remarks:

 If the sets “A” and “B” are not disjoint, then 𝑨 ∪ 𝑩 = 𝑨 + 𝑩 − 𝑨 ∩ 𝑩

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

 A total of: 𝑨 ∪ 𝑩 = 𝑨 + 𝑩 − 𝑨 ∩ 𝑩 = 𝟒𝟎𝟎 + 𝟒𝟓𝟎 − 𝟐𝟎𝟎 = 𝟔𝟓𝟎

Dr. M. Alkrunz
December 5, 2022 8
EEE247: Discrete Mathematics
Basic of Counting,,,
Pigeonhole Principle

 If there is “≥ 𝑘 + 1” objects that assigned to “𝑘”


places. Then, at least 1 place must be assigned “≥ 2”
objects.

 I mean, the number of pigeons is more than the


number of pigeonholes.

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.

 How many people must be selected from a collection of 15 married couples


to ensure that at least two of the chosen persons are married to each
other?
 The worst case to select 15 males or 15 females.
 Selection of 16 persons ensures that.

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.

Generalized Pigeonhole Principle


 If “N” objects are assigned to “K” places, then at least one place must be
assigned at least 𝑁Τ𝐾 objects.
Example:
 If there are (N = 280) students in class. There are (K = 52) weeks in the year.
 Therefore, there must be at least 1 week during year which at least
280Τ
52 = 6 students in the class have a birthday.
Dr. M. Alkrunz
December 5, 2022 11
EEE247: Discrete Mathematics
Permutation & Combinations
 A permutation of a set “S” of objects is a sequence that contains each
object in “S” exactly once. [No Repetition]

 An ordered arrangement of “r” distinct elements of “S” is called r-


permutation of “S”.

 The number of r-permutations of a set “S” with 𝑛 = 𝑆 elements is:

𝒏!
𝑷 𝒏, 𝒓 = 𝒏 𝒏 − 𝟏 𝒏 − 𝟐 … … … 𝒏 − 𝒓 + 𝟏 =
𝒏−𝒓 !

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.

 After we choose an object:

 We can replace it (Selection with replacement). [Probability Course]

 Or not (Selection without replacement). [This case is considered]

 How many different possible sequence for “r” objects are there?!!!

 Does the order of the objects matter or not?!!!

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.

[Permutation of the objects]

 How many different arrangements (Ordered Lists) of “r” objects can be


formed from a set of “n” distinct objects?

[Combination of the objects]

 How many different selections (Unordered Lists) of “r” objects can be


made from a set of “n” distinct objects?
Dr. M. Alkrunz
December 5, 2022 14
EEE247: Discrete Mathematics
Permutation
Permutation:

 It is an arrangement or ordering of “n” distinct objects.

 If 𝑟 ≤ 𝑛, then the arrangement using “r” of the “n” distinct objects is called
r-permutation.

 The number of different r-permutations of a set of “n” distinct elements is


denoted as 𝑃(𝑛, 𝑟),

𝒏!
𝑷 𝒏, 𝒓 = 𝒏 𝒏 − 𝟏 𝒏 − 𝟐 … … … 𝒏 − 𝒓 + 𝟏 =
𝒏−𝒓 !

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?!!

 The number of ordered cutting from 10 wires:

𝑛! 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!

If you remember the previous technique, it gives the same answer:

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.

 Let "𝑆" be the set 1, 2, 3, 4 . Then, 1, 3, 4 is a 3-combination from "𝑆“.

 Note that 4, 1, 3 is the same combinations as 1, 3, 4 since the order in


which the elements of a set are listed 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:

𝑷 𝒏, 𝒓 𝒏!
𝑪 𝒏, 𝒓 = =
𝑷 𝒓, 𝒓 𝒓! 𝒏 − 𝒓 !

 Selection of r-combinations of n-elements is the same like outing (n-r)-


combination from n-elements
𝑪 𝒏, 𝒓 = 𝑪 𝒏, 𝒏 − 𝒓

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!

 They are: 0011, 0101, 1001, 0110, 1010, 1100

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, 3) possibilities for Math, and 𝐶(11, 4) possibilities for Physics.

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!

 Exactly one head:

 𝐶 𝑛, 1

 Exactly two heads:

 𝐶 𝑛, 2

 Exactly “r” heads:

 𝐶 𝑛, 𝑟
Dr. M. Alkrunz
December 5, 2022 24
EEE247: Discrete Mathematics
Combinations
Example: (Continue)

 At least two heads:

 𝐶 𝑛, 2 + 𝐶 𝑛, 3 + 𝐶 𝑛, 4 + . . . . . . . . . . . . . . . +𝐶(𝑛, 𝑛) [too long]

 Or: 2𝑛 − 𝐶 𝑛, 0 − 𝐶(𝑛, 1) [where: 𝟐𝒏 is all the possibilities]

Dr. M. Alkrunz
December 5, 2022 25
EEE247: Discrete Mathematics
Binomial Coefficients
 We will now study some properties of the binomial coefficients.

 First, the binomial theorem:

𝑛
𝑛
𝑛 𝑛−𝑗 𝑗 𝑛 𝑛 𝑛 𝑛−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 (𝒙 + 𝒚)𝟑 ?!!

 We know: (𝑥 + 𝑦)3 = 𝑥 3 + 𝟑𝒙𝟐 𝒚 + 3𝑥𝑦 2 + 𝑦 3

3!
 𝐶 3, 2 = 𝐶 3,1 = =3
2! 1!

Example:
What is the coefficient of 𝒙𝟏𝟐 𝒚𝟏𝟑 in the expression of (𝒙 + 𝒚)𝟐𝟓 ?!!

 Let us apply the same idea as the previous example

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 (𝟐𝒙 − 𝟑𝒚)𝟐𝟓 ?!!

 First, replace 𝒂 = 𝟐𝒙 and 𝒃 = −𝟑𝒚

 The coefficient of 𝑎12 𝑏13 in (𝑎 + 𝑏)25 is 𝑪(𝟐𝟓, 𝟏𝟐)

𝐶 25, 12 𝑎12 𝑏13 =


𝐶 25, 12 (2𝑥)12 (−3𝑦)13 =

𝑪 𝟐𝟓, 𝟏𝟐 (𝟐)𝟏𝟐 (−𝟑)𝟏𝟑 𝑥 12 𝑦13


𝑐𝑜𝑒𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑡

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

You might also like