2 Counting Methods
2 Counting Methods
Faculty of Engineering
Electrical and Electronics Engineering Department
Counting Methods
Salma Elkawafi
[email protected]
Counting Methods
In studying probability, it is usually effective to use
some counting methods to compute the possible
outcomes of a certain experiment.
The followings are some of the most important
methods of counting:
• Inclusion-exclusion principle
• The basic principle of counting (Multiplication): ordered
sampling with replacement
• Permutations: Ordered Sampling without Replacement
• Combinations: Unordered Sampling without Replacement
• Multinomial Coefficients
• Unordered Sampling with Replacement
Counting Methods
• Inclusion-exclusion principle
• The inclusion-exclusion principle says
|𝐴 ∪ 𝐵| = |𝐴| + |𝐵| − |𝐴 ∩ 𝐵|
| A | = #A = n(A)
Counting Methods
|𝐴 ∪ 𝐵 ∪ 𝐶| = |𝐴| + |𝐵| + |𝐶| − |𝐴 ∩ 𝐵| − |𝐴 ∩ 𝐶| − |𝐵 ∩ 𝐶| + |𝐴 ∩ 𝐵 ∩ 𝐶|
Counting Methods
• Inclusion-exclusion principle
Example:
In a band of singers and pianists, seven people sing, four play the
piano, and two do both. How big is the band?
Solution:
Let S be the set singers and P be the set piano players. The inclusion
exclusion principle says size of band is
|𝑆 ∪ 𝑃| = |𝑆| + |𝑃| − |𝑆 ∩ 𝑃| = 7 + 4 − 2 = 9.
Counting Methods
• Inclusion-exclusion principle
Example:
50 students taking examinations in Mathematics, Physics and Chemistry, each of the student has
passed in at least one of the subject, 37 passed Mathematics, 24 Physics and 43 Chemistry. At most
19 passed Mathematics and Physics, at most 29 Mathematics and Chemistry and at most 20 Physics
and Chemistry. What is the largest possible number that could have passed all three examination?
Solution :
Let M be the set of students passing in Mathematics
P be the set of students passing in Physics
C be the set of students passing in Chemistry Now,
• 𝑛 𝑀 ∪ 𝑃 ∪ 𝐶 = 50, 𝑛 𝑀 = 37, 𝑛 𝑃 = 24, 𝑛 𝐶 = 43 , 𝑛 𝑀 ∩ 𝑃 ≤ 19, 𝑛(𝑀 ∩ 𝐶) ≤ 29
, 𝑛(𝑃 ∩ 𝐶) ≤ 20 (Given)
𝑛(𝑀 ∪ 𝑃 ∪ 𝐶)
= 𝑛(𝑀) + 𝑛(𝑃) + 𝑛(𝐶) – 𝑛(𝑀 ∩ 𝑃) – 𝑛(𝑀 ∩ 𝐶) – 𝑛(𝑃 ∩ 𝐶) + 𝑛(𝑀 ∩ 𝑃 ∩ 𝐶) ≤ 50
⇒ 37 + 24 + 43 – 19 – 29 – 20 + 𝑛(𝑀 ∩ 𝑃 ∩ 𝐶) ≤ 50
⇒ 𝑛 𝑀 ∩ 𝑃 ∩ 𝐶 ≤ 50 – 36
⇒ 𝑛(𝑀 ∩ 𝑃 ∩ 𝐶) ≤ 14
Counting Methods
• The basic principle of counting (Multiplication)
• If there are 𝑛 ways to perform action 1 and then by m ways to perform action
2, then there are 𝑛 · 𝑚 ways to perform action 1 followed by action 2.
Or
• It states that if one experiment can result in any of 𝑚 possible outcomes and if
another experiment can result in any of 𝑛 possible outcomes, then there are
𝑚𝑛 possible outcomes of the two experiments.
Counting Methods
• The basic principle of counting (Multiplication)
Multiplication Principle
• Suppose that we perform 𝑟 experiments such that the 𝑘𝑡ℎ experiment
has 𝑛𝑘 possible outcomes, for 𝑘 = 1,2, ⋯ , 𝑟. Then there are a total of
𝑛1 × 𝑛2 × 𝑛3 × ⋯ × 𝑛𝑟 possible outcomes for the sequence of 𝑟
experiments.
• Sampling: sampling from a set means choosing an element from that set. We often draw a sample at
random from a given set in which each element of the set has equal chance of being chosen.
• With or without replacement: usually we draw multiple samples from a set. If we put each object back
after each draw, we call this sampling with replacement. In this case a single object can be possibly
chosen multiple times. For example, if 𝐴 = {𝑎1 , 𝑎2 , 𝑎3 , 𝑎4 } and we pick 3 elements with replacement, a
possible choice might be (𝑎3 , 𝑎1 , 𝑎3 ). Thus "with replacement" means "repetition is allowed." On the
other hand, if repetition is not allowed, we call it sampling without replacement.
Thus when we talk about sampling from sets, we can talk about four possibilities.
so there are a 𝑃66 × 𝑃44 = 720 × 24 of possible rankings in total (basic principle of
counting)
10! 10×9×8×7×6×5×4×3×2×1
c) There are 𝑃310 possible rankings = = = 10 × 9 × 8 = 720
10−3 ! 7×6×5×4×3×2×1
Counting Methods
• Combinations: Unordered Sampling without Replacement
Here we have a set with 𝑛 elements, e.g., 𝐴 = {1,2,3, … . 𝑛} and we want to
draw 𝑘 samples from the set such that ordering does not matter and
repetition is not allowed. Thus, we basically want to choose a 𝑘-element
subset of 𝐴, which we also call a 𝑘-combination of the set 𝐴. For example if 𝐴
= {1,2,3} and 𝑘 = 2, there are 3 different possibilities:
{1,2};
{1,3};
{2,3}.
We show the number of k-element subsets of A by
𝑛
.
𝑘
This is read "n choose k."
Counting Methods
• Combinations: Unordered Sampling without Replacement
Simply, when we are counting the number of subgroups of size 𝑘 from a
larger group of size n considering NO ORDER, we use combinations.
We define combinations as
𝑛 𝑛 𝑛!
𝐶𝑘 = =
𝑘 𝑘! 𝑛 − 𝑘 !
5! 5×4×3×2×1
𝐶35 = =
3! 5 − 3 ! 3×2×1×2×1
Counting Methods
• Combinations
Example:
A committee of 3 is to be formed from a group of 20 people. How many
different committees are possible?
Solution
20! 20×19×18
There are 𝐶320 = 20
3
= = = 1140 possible
3! 20−3 ! 3×2×1
committees can be formed
Counting Methods
• Combinations
Example:
From a group of 5 women and 7 men
a) How many different committees consisting of 2 women and 3 men can be formed?
b) What if 2 of the men are refusing to work together in one committee?
Solution
a) There are 𝐶25 of possible groups of women and 𝐶37 of possible groups of men. So, the total
number of possible committees is
5×4 7×6×5×4
𝐶25 × 𝐶37 = ( )( ) = 350
2×1 3×2×1
b) Now, for two men to be together, there are 𝐶22 × 𝐶15 = 1 × 5 ways.
We remove these 5 ways from 𝐶37 of total possible groups of men, so there are now 35-5=30
of possible groups of men and by considering the number of women groups, we have a total
of 𝐶25 × 30 = 10 × 30 or 300 different possible committees.
Counting Methods
• Combinations
Example:
What is the number of ways of choosing 4 cards from a pack of 52 playing cards? In how many of
these
(i) four cards are of the same suit, (ii) four cards belong to four different suits,
Solution
• There will be as many ways of choosing 4 cards from 52 cards as there are combinations of 52
different things, taken 4 at a time. Therefore The required number of ways = 𝐶452 = 270725
(i) There are four suits: diamond, club, spade, heart and there are 13 cards of each suit. Therefore, The
required number of ways = 𝐶413 + 𝐶413 + 𝐶413 + 𝐶413 = 2860
(ii) There are13 cards in each suit. Therefore, there are 𝐶113 ways of choosing 1 card from 13 cards of
diamond, 𝐶113 ways of choosing 1 card from 13 cards of hearts, 𝐶113 ways of choosing 1 card from 13
cards of clubs, 𝐶113 ways of choosing 1 card from 13 cards of spades. Hence, by multiplication principle,
the required number of ways = 𝐶113 × 𝐶113 × 𝐶113 × 𝐶113 = 134
Counting Methods
• Multinomial Coefficients
𝑛 𝑛!
=
𝑛1 , 𝑛2 , ⋯ , 𝑛𝑟 𝑛1 ! 𝑛2 ! … . 𝑛𝑟 !
Counting Methods
• Multinomial Coefficients
Example: How many different letter arrangements can be formed from the letters
PEPPER?
Solution
6!
There are 6
3 ,2,1
= 3!2!1! = 60 possible letter arrangements can be formed
Counting Methods
• Multinomial Coefficients
Example:
A police department consists of 10 officers, 5 of them work in streets, 3 in cars,
and 2 in the building. How many different divisions of the 10 officers into the
three groups are possible?
Solution:
10!
There are 10
5 ,3,2
= 5!3!2! = 2520 possible divisions
Counting Methods
• Unordered Sampling with Replacement
• Suppose that we want to sample from the set 𝐴 = {𝑎1 , 𝑎2 , … , 𝑎𝑛 } 𝑘 times such
that repetition is allowed and ordering does not matter. For example, if 𝐴
= {1,2,3} and 𝑘 = 2, then there are 6 different ways of doing this
The number of different ways of picking 𝑘 objects from a set of 𝑛 distinct objects
with replacement and without ordering is given by= 𝑛+𝑘−1𝑘
.
Self-Study
Summary
End of Lecture 2
A total of 36 members of a club play tennis, 28 play squash, and 18
play badminton. Furthermore, 22 of the members play both tennis
and squash, 12 play both tennis and badminton, 9 play both squash
and badminton. How many members play all three sports if 43
members of this club play at least one of the three sports?
Exercise
Answer:
There are 3 × 4 × 5 × 2 = 120 possible subcommittees
Exercise
Answer:
Let the points be 1, 2, . . . , 𝑛. Since 𝑓(𝑖) must be either 0 or 1 for each i
= 1, 2, . . . , n, it follows that there are 2𝑛 possible functions.
Exercise
There are 5 competitors in the 100m final at the Olympics. In how many
ways can the gold, silver, and bronze medals be awarded?
Answer:
There are 5 ways to award the gold. Once that is awarded there are 4
ways to award the silver and then 3 ways to award the bronze: answer
5 · 4 · 3 = 60 ways.
Exercise
Ms Jones has 4 math, 3 physics, 2 chemistry and 1 language books. She wants to
arrange these books on a bookshelf so that all books of the same subject are kept
together. How many different arrangements are possible?
Answer:
There are 𝑃44 possible arrangements for math books , 𝑃33 possible arrangements for
physics books, 𝑃22 possible arrangements for physics books, and 𝑃11 possible
arrangements for language book. Also, we have 4 subjects that can have
𝑃44 possible arrangements . So, there are 𝑃44 ×𝑃44 × 𝑃33 × 𝑃22 × 𝑃11 = 6912 possible
arrangements in total ( generalized basic principle of counting)
Exercise
How many numbers lying between 100 and 1000 can be formed with the digits 0, 1, 2,
3, 4, 5, if the repetition of the digits is not allowed?
Answer:
Every number between 100 and 1000 is a 3-digit number. We, first, have to count
the permutations of 6 digits taken 3 at a time 𝑃36 . But, these permutations will
include those also where 0 is at the 100’s place. For example, 092, 042, . . ., etc
are such numbers which are actually 2-digit numbers and hence the number
of such numbers has to be subtracted from 𝑃36 to get the required number.
To get the number of such numbers, we fix 0 at the 100’s place and rearrange
the remaining 5 digits taking 2 at a time.
6! 5!
So The required number 𝑃36 − 𝑃25 = − = 100
3! 3!
Exercise
Count the following:
(i) The number of ways to choose 2 out of 4 things (order does not matter).
(ii) The number of ways to list 2 out of 4 things.
(iii) The number of ways to choose 3 out of 10 things.
Answer:
4! 4!
(i) This is asking for combinations: C24 = = =6
2! 4−2 ! 2!×2!
4! 4!
(ii) This is asking for permutations: 𝑃24 = = = 12
4−2 ! 2!
10! 10! 10×9×8
(iii) This is asking for combinations: C310 = = = = 120
3! 10−3 ! 3! × 7! 3×2×1
Exercise
Count the number of ways to get 3 heads in a sequence of 10 flips of a
coin.
Answer:
This asks for the number sequences of 10 flips (heads or tails) with exactly
3 heads. That is, we have to choose exactly 3 out of 10 flips to be heads.
This is the same question as in the previous example:
Answer:
Answer:
12!
There are = 27720 arrangements
6!4!
.
Exercise
A maths debating team consists of 4 speakers
a) In how many ways can all 4 speakers be arranged in a row for a photo?
b) How many ways can the captain and vice-captain be chosen?
Answer:
4
a) 4 × 3 × 2 × 1 = 4! 𝑜𝑟 𝑃4
4
b) 4 × 3 = 12 or 𝑃2
Exercise
Consider the following data among 110 students in a college dormitory: 30 students are on a
list A (taking Accounting), 35 students are on a list B (taking Biology), 20 students are on both
lists. Find the number of students:
(a) on list or B,
( b) on exactly one of the two lists,
( c) on neither list.
Answer:
(a) 𝑛(𝐴 𝑈 𝐵) = 𝑛(𝐴) + 𝑛(𝐵) − 𝑛(𝐴 𝑛 𝐵) = 30 + 35 − 20 = 45
Answer:
(𝑎) 8! = 40,320
(𝑏) 2 ⋅ 7! = 10,080
Exercise
In how many ways can 5 boys and 4 girls be arranged on a bench if:
(a) boys and girls alternate?
(b) boys and girls are in separate groups?
Answer:
(a) 𝐵𝐺𝐵𝐺𝐵𝐺𝐵𝐺𝐵 = 5 × 4 × 4 × 3 × 3 × 2 × 2 × 1 × 1 = 5! × 4!
(b) Boys & Girls or Girls & Boys
= 5! × 4! + 4! × 5! = 5! × 4! × 2