Discrete Mathematics (13) (14) Counting
Discrete Mathematics (13) (14) Counting
Counting
Session 13-14
Acknowledgement
Chapter 6 and 8
2
Learning Objectives
LO 2
Explain Set Theory, Fuzzy Set,
Counting method, Number Theory and
its applications
Sub Topics
• Principle of Inclusion–Exclusion
4
4
The Basics of Counting
5
Introduction
6
Basic Counting Principles
Example 1 :
A new company with just two employees, Sanchez and Patel, rents a floor of a
building with 12 offices. How many ways are there to assign different offices to
these two employees?
Example 2:
How many different license plates can be made if each plate contains a
sequence of three uppercase English letters followed by three digits (and no
sequences of letters are prohibited, even if they are obscene)?
7
The Product Rule
Solution :
1. The procedure of assigning offices to these two employees consists of
assigning an office to Sanchez, which can be done in 12 ways, then
assigning an office to Patel different from the office assigned to Sanchez,
which can be done in 11 ways. By the product rule, there are
12 ⋅ 11 = 132 ways to assign offices to these two employees.
2. There are 26 choices for each of the three uppercase English letters and
10 choices for each of the three digits. Hence, by the product rule there
are a total of
26 ⋅ 26 ⋅ 26 ⋅ 10 ⋅ 10 ⋅ 10
= 17,576,000 possible license plates
8
The Product Rule
Example 3 :
What is the value of k after the following code, where n1, n2,…, nm are
positive integers, has been executed?
Solution :
The initial value of k is zero. Each time the nested
loop is traversed, 1 is added to k.
Let Ti be the task of traversing the ith loop.
Then the number of times the loop is traversed is
the number of ways to do the tasks T1, T2,…, Tm.
The number of ways to carry out the task Tj, j = 1,
2,…, m, is nj, because the jth loop is traversed
once for each integer ij with 1 ≤ ij ≤ nj.
By the product rule, it follows that the nested loop
is traversed n1n2⋯nm times.
Hence, the final value of k is n1n2⋯nm.
9
2. The Sum Rule
Example 1:
A student can choose a computer project from one of three lists. The three lists
contain 23, 15, and 19 possible projects, respectively. No project is on more
than one list. How many possible projects are there to choose from?
Solution:
The student can choose a project by selecting a project from the first list, the
second list, or the third list. Because no project is on more than one list, by the
sum rule there are 23 + 15 + 19 = 57 ways to choose a project.
10
2. The Sum Rule
Example 2
What is the value of k after the following code, where n1, n2,…, nm are
positive integers, has been executed?
Solution :
The initial value of k is zero. This block of code is made
up of m different loops. Each time a loop is traversed, 1
is added to k,
We need to determine how many times we traverse a
loop. Note that there are ni ways to traverse the ith
loop. Because we only traverse one loop at a time, the
sum rule shows that the final value of k, which is the
number of ways to traverse one of the m loops is
n1 + n2 +⋯+ nm.
11
2. The Sum Rule
Example 3 :
Each user on a computer system has a password, which is six to eight
characters long, where each character is an uppercase letter or a digit.
Each password must contain at least one digit. How many possible
passwords are there?
Solution:
Let P be the total number of possible passwords, and let P6, P7, and P8
denote the number of possible passwords of length 6, 7, and 8, respectively.
The number of strings of six characters is 366, and the number of strings with no digits is
266
Example :
A computer company receives 350 applications from college graduates for a
job planning a line of new web servers. Suppose that 220 of these applicants
majored in computer science, 147 majored in business, and 51 majored both
in computer science and in business. How many of these applicants majored
neither in computer science nor in business?
Solution :
Let A1 : the set of students who majored in computer science
A2 : the set of students who majored in business.
A1 ∪ A2 : the set of students who majored in computer science or
business A1 ∩ A2 : the set of students who majored both in computer
science and in business.
Solution :
15
4. The Division Rule
Example :
How many different ways are there to
seat four people around a circular table,
where two seatings are considered the
same when each person has the same
left neighbor and the same right
neighbor?
16
The Division Rule
Solution:
We arbitrarily select a seat at the table and label it seat 1. We number the
rest of the seats in numerical order, proceeding clockwise around the table.
Note that are four ways to select the person for seat 1, three ways to select
the person for seat 2, two ways to select the person for seat 3, and one way
to select the person for seat 4.
Thus, there are 4! = 24 ways to order the given four people for these seats.
However, each of the four choices for seat 1 leads to the same
arrangement, as we distinguish two arrangements only when one of the
people has a different immediate left or immediate right neighbor.
Because there are four ways to choose the person for seat 1, by the
division rule there are 24∕4 = 6 different seating arrangements of four people
around the circular table.
17
5. Tree Diagrams
Example :
A playoff between two teams consists
of at most five games. The first team
that wins three games wins the
playoff. In how many different ways
can the playoff occur?
Solution:
The tree diagram in Figure below displays all the ways the playoff can
proceed, with the winner of each game shown. We see that there are 20
different ways for the playoff to occur.
19
The Pigeonhole Principle
20
The Pigeonhole Principle
Theorem 1
If k is a positive integer and k + 1 or more objects are placed into k boxes,
then there is at least one box containing two or more of the objects.
Proof:
We prove the pigeonhole principle
using a proof by contraposition.
Suppose that none of the k boxes
contains more than one object. Then
the total number of objects would be
at most k.
This is a contradiction, because there
are at least k + 1 objects
This Photo by Unknown Author is licensed under CC BY-SA
21
The Pigeonhole Principle
Corollary 1
A function f from a set with k + 1 or more elements to a set with k elements is
not one-to-one.
Proof:
Suppose that for each element y in the codomain of f we have a box that
contains all elements x of the domain of f such that f (x) = y. Because the
domain contains k + 1 or more elements and the codomain contains only k
elements, the pigeonhole principle tells us that one of these boxes contains
two or more elements x of the domain. This means that f cannot be one-to-
one.
22
The Pigeonhole Principle
Example 1 :
Among any group of 367 people, there must be at least two with the same
birthday, because there are only 366 possible birthdays.
Example 2 :
How many students must be in a class to guarantee that at least two
students receive the same score on the final exam, if the exam is graded on
a scale from 0 to 100 points?
Solution :
There are 101 possible scores on the final. The pigeonhole principle shows
that among any 102 students there must be at least 2 students with the same
score.
23
Applications of the Pigeonhole
Principle
Example :
During a month with 30 days, a baseball team plays at least one game a day,
but no more than 45 games. Show that there must be a period of some number
of consecutive days during which the team must play exactly 14 games.
Solution:
Let aj be the number of games played on or before the jth day of the month.
Then a1, a2,…, a30 is an increasing sequence of distinct positive integers, with
1 ≤ aj ≤ 45. Moreover, a1 + 14, a2 + 14,…, a30 + 14 is also an increasing
sequence of distinct positive integers, with 15 ≤ aj + 14 ≤ 59.
The 60 positive integers a1, a2,…, a30, a1 + 14, a2 + 14,…, a30 + 14 are all
less than or equal to 59.
Hence, by the pigeonhole principle two of these integers are equal. Because the
integers aj, j = 1, 2,…, 30 are all distinct and the integers aj + 14, j = 1, 2,…, 30
are all distinct, there must be indices i and j with ai = aj + 14. This means that
exactly 14 games were played from day j + 1 to day i.
24
Permutations and Combinations
25
Permutations
Theorem 1
If n is a positive integer and r is an integer with 1 ≤ r ≤ n, then there are
P(n, r) = n(n − 1)(n − 2)⋯(n − r + 1)
r-permutations of a set with n distinct elements.
26
Permutations
Corollary 1
If n and r are integers with 0 ≤ r ≤ n, then P(n, r) = n!
(n − r)!
Proof:
When n and r are integers with 1 ≤ r ≤ n, by Theorem 1 we have
P(n, r) = n(n − 1)(n − 2)⋯(n − r + 1) = n!
(n − r)!
Because
n! = n! = 1
(n − 0)! n!
whenever n is a nonnegative integer, we see that the formula
P(n, r) = n! also holds when r = 0
(n − r)!
By Theorem 1 we know that if n is a positive integer, then P(n, n) = n!.
27
Permutations
Example 1 :
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?
Solution:
Because it matters which person wins which prize, the number of ways to
pick the three prize winners is the number of ordered selections of three
elements from a set of 100 elements, that is, the number of 3-permutations
of a set of 100 elements.
Consequently, the answer is
P(100, 3) = 100 ⋅ 99 ⋅ 98 = 970,200.
28
Permutations
Example 2 :
Suppose that a saleswoman has to visit eight different cities. She must
begin her trip in a specified city, but she can visit the other seven cities in
any order she wishes. How many possible orders can the saleswoman use
when visiting these cities?
Solution:
The number of possible paths between the cities is the number of
permutations of seven elements, because the first city is determined, but
the remaining seven can be ordered arbitrarily.
Consequently, there are 7! = 7 ⋅ 6 ⋅ 5 ⋅ 4 ⋅ 3 ⋅ 2 ⋅ 1 = 5040 ways for the
saleswoman to choose her tour.
29
Permutations with Repetition
Example :
How many strings of length r can be formed from the uppercase letters of
the English alphabet?
Solution:
By the product rule, because there are 26 uppercase English letters, and
because each letter can be used repeatedly, we see that there are 26𝑟
strings of uppercase English letters of length r.
Theorem
The number of r-permutations of a set of n objects with repetition allowed is 𝑛𝑟
30
Combinations
Theorem 2
The number of r-combinations of a set with n elements, where n is a
nonnegative integer and r is an integer with 0 ≤ r ≤ n, equals
C(n, r) = n!
r! (n − r)! .
31
Combinations
Corollary 2
Let n and r be nonnegative integers with r ≤ n. Then C(n, r) = C(n, n − r).
Proof:
From Theorem 2 it follows that
C(n, r) = n!
r! (n − r)!
and
C(n, n − r) = n!
(n − r)! [n − (n − r)]!
= n!
(n − r)! r!.
Hence, C(n, r) = C(n, n − r).
32
Combinations
Example 1 :
A group of 30 people have been trained as astronauts to go on the first
mission to Mars. How many ways are there to select a crew of six people to
go on this mission (assuming that all crew members have the same job)?
Solution:
The number of ways to select a crew of six from the pool of 30 people is the
number of 6-combinations of a set with 30 elements, The number of such
combinations is
C(30, 6) = 30!
6! 24!
= 30 ⋅ 29 ⋅ 28 ⋅ 27 ⋅ 26 ⋅ 25 . 6 ⋅ 5 ⋅ 4 ⋅ 3 ⋅ 2 ⋅ 1
= 593,775.
33
Combinations
Example
Suppose that there are 9 faculty members in the mathematics department and
11 in the computer science department. How many ways are there to select a
committee to develop a discrete mathematics course at a school if the
committee is to consist of three faculty members from the mathematics
department and four from the computer science department?
Solution:
The answer is the product of the number of 3-combinations of a set with nine
elements and the number of 4-combinations of a set with 11 elements, the
number of ways to select the committee is
Example
How many ways are there to select four pieces of fruit from a bowl containing
apples, oranges, and pears if the order in which the pieces are selected does
not matter, only the type of fruit and not the individual piece matters, and there
are at least four pieces of each type of fruit in the bowl?
Solution:
To solve this problem we list all the ways possible to select the fruit. There are
15 ways:
4 apples 4 oranges 4 pears
3 apples, 1 orange 3 apples, 1 pear 3 oranges, 1 apple
3 oranges, 1 pear 3 pears, 1 apple 3 pears, 1 orange
2 apples, 2 oranges 2 apples, 2 pears 2 oranges, 2 pears
2 apples, 1orange, 1pear 2 oranges, 1 apple, 1 pear 2 pears, 1 apple, 1 orange
Theorem 2
There are C(n + r − 1, r) = C(n + r − 1, n − 1) r-combinations from a set with
n elements when repetition of elements is allowed.
Example :
Suppose that a cookie shop has four different kinds of cookies. How many
different ways can six cookies be chosen? Assume that only the type of
cookie, and not the individual cookies or the order in which they are chosen,
matters.
Solution:
C(4 + 6 − 1, 6) = C(9, 6). Because
C(9, 6) = C(9, 3) = 9 ⋅ 8 ⋅ 7
1⋅2⋅3
= 84,
there are 84 different ways to choose the six cookies.
36
Combinations and Permutations With
and Without Repetition.
37
Permutations with Indistinguishable
Objects
Example :
How many different strings can be made by reordering the letters of the word
SUCCESS?
Solution:
Because some of the letters of SUCCESS are the same, the answer is not
given by the number of permutations of seven letters. This word contains
three Ss, two Cs, one U, and one E.
Consequently, from the product rule, the number of different strings that can
be made is
C(7, 3)C(4, 2)C(2, 1)C(1, 1) = 7! ⋅ 4! . 2! ⋅ 1!
3! 4! 2! 2! 1! 1! 1! 0!
= 7!
3! 2! 1! 1!
= 420.
38
Permutations with
Indistinguishable Objects
THEOREM
The number of different permutations of n objects, where there are n1
indistinguishable objects of type 1, n2 indistinguishable objects of type 2,…,
and nk indistinguishable objects of type k, is
n!
n1! n2!⋯nk!
39
Distinguishable Objects And
Distinguishable Boxes
Example :
How many ways are there to distribute hands of 5 cards to each of four
players from the standard deck of 52 cards?
Solution:
The first player can be dealt 5 cards in C(52, 5) ways.
The second player can be dealt 5 cards in C(47, 5) ways, because only 47
cards are left.
The third player can be dealt 5 cards in C(42, 5) ways.
Finally, the fourth player can be dealt 5 cards in C(37, 5) ways.
Hence, the total number of ways to deal four players 5 cards each is
C(52, 5)C(47, 5)C(42, 5)C(37, 5) = 52! ⋅ 47! ⋅ 42! 37!
47! 5! 42! 5! 37! 5! ⋅ 32! 5!
= 52!
5! 5! 5! 5! 32! .
40
Indistinguishable Objects And
Distinguishable Boxes
Example :
How many ways are there to place 10 indistinguishable balls into eight
distinguishable bins?
Solution:
The number of ways to place 10 indistinguishable balls into eight bins equals
the number of 10-combinations from a set with eight elements when
repetition is allowed.
Consequently, there are
C(8 + 10 − 1, 10) = C(17, 10) = 17!
10!7!
= 19,448.
41
Indistinguishable Objects And
Indistinguishable Boxes
Example :
How many ways are there to pack six copies of the same book into four
identical boxes, where a box can contain as many as six books?
Solution:
For each way to pack the books, we will list the number of books in the box
with the largest number of books, followed by the numbers of books in each
box containing at least one book, in order of decreasing number of books in a
box. The ways we can pack the books are
6
5, 1
4, 2 3, 2, 1
4, 1, 1 3, 1, 1, 1
3, 3 2, 2, 2
2, 2, 1, 1.
We conclude that there are nine allowable ways to pack the books
42
Principle Of Inclusion–Exclusion
43
The Principle Of Inclusion–Exclusion
of n sets
Theorem 1
Let A1, A2,…, An be finite sets. Then
44
Principle Of Inclusion–
Exclusion For Three Sets
Count of elements by
46
Principle Of Inclusion–
Exclusion For Three Set
Then
|S| = 1232, |F| = 879, |R| = 114,
|S ∩ F| = 103, |S ∩ R| = 23, |F ∩ R| = 14, and
|S ∪ F ∪ R| = 2092.
48
Binomial Coefficients and Identities
49
The Binomial Theorem
THEOREM 1
The binomial theorem . Let x and y be variables, and let n be a nonnegative
integer. Then
Example :
a. What is the expansion of(x + y) 4 ?
b. What is the coefficient of 𝑥 12 𝑦 13 in the expansion of (2x − 3y)25 ?
50
The Binomial Theorem
Solution:
51
The Binomial Theorem
Solution :
52
The Binomial Theorem
Corollary 1
Let n be a nonnegative integer. Then
Corollary 2
Let n be a positive integer. Then
Corollary 3
Let n be a nonnegative integer. Then
53
Pascal’s Identity and Triangle
Theorem 2
Pascal’s Identity . Let n and k be positive integers with n ≥ k.
Then
This triangle is known as Pascal’s triangle, named after the French mathematician Blaise
Pascal
54
Pascal’s triangle
55
Reference
56
Thank You