0% found this document useful (0 votes)
78 views57 pages

Discrete Mathematics (13) (14) Counting

Uploaded by

jsenwj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views57 pages

Discrete Mathematics (13) (14) Counting

Uploaded by

jsenwj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Course : MATH6025 – Discrete Mathematics

Effective Period : September 2020

Counting
Session 13-14
Acknowledgement

These slides have been adapted from :

Kenneth H. Rosen, “ Discrete


Mathematics and its Applications”,
8th edition,2019, McGraw-Hill
Education, New York, ISBN 978-1-
259-67651-2

Chapter 6 and 8

2
Learning Objectives

On successful completion of this course, students will be able


to:

LO 2
Explain Set Theory, Fuzzy Set,
Counting method, Number Theory and
its applications
Sub Topics

• The Basics of Counting


1

• The Pigeonhole Principle


2

• Permutations and Combinations


3

• Principle of Inclusion–Exclusion
4

• Binomial Coefficients and Identities


5

4
The Basics of Counting

5
Introduction

 Counting problems arise throughout mathematics and computer


science.
 For example, we must count the successful outcomes of experiments
and all the possible outcomes of these experiments to determine
probabilities of discrete events.
 We need to count the number of operations used by an algorithm to
study its time complexity.
 We will introduce the basic techniques of counting, these methods serve
as the foundation for almost all counting techniques.

6
Basic Counting Principles

1. THE PRODUCT RULE


Suppose that a procedure can be broken down into a sequence of two tasks.
If there are n1 ways to do the first task and for each of these ways of doing
the first task, there are n2 ways to do the second task, then there are n1n2
ways to do the procedure

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

The Sum Rule


If a task can be done either in one of n1 ways or in one of n2 ways, where
none of the set of n1 ways is the same as any of the set of n2 ways, then there
are n1 + n2 ways to do the task.

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

P6 = 366 − 266 = 2,176,782,336 − 308,915,776 = 1,867,866,560


P7 = 367 − 267 = 78,364,164,096 − 8,031,810,176 = 70,332,353,920
P8 = 368 − 268 = 2,821,109,907,456 − 208,827,064,576= 2,612,282,842,880
Hence, P = P6 + P7 + P8 = 2,684,483,063,360.
12
3. The Subtraction Rule

THE SUBTRACTION RULE


If a task can be done in either n1 ways or n2 ways, then the number of ways to
do the task is n1 + n2 minus the number of ways to do the task that are
common to the two different ways.

The subtraction rule is also known as the principle of inclusion exclusion,


especially when it is used to count the number of elements in the union of two
sets.
Suppose that A1 and A2 are sets. Then
|A1| ways to select an element from A1
|A2| ways to select an element from A2.
|A1 ∩ A2| ways to select an element common to both sets
| A1 ∪ A2 | ways to select an element in either A1 or in A2

|A1 ∪ A2| = |A1| + |A2| − |A1 ∩ A2|.


13
3. The Subtraction Rule

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.

|A1 ∪ A2| = |A1| + |A2| − |A1 ∩ A2| = 220 + 147 − 51 = 316.


We conclude that 350 − 316 = 34 of the applicants majored neither in
computer science nor in business.
14
Venn Diagram

Solution :

15
4. The Division Rule

The Division Rule


There are n∕d ways to do a task if it can be done using a procedure that can
be carried out in n ways, and for every way w, exactly d of the n ways
correspond to way w.

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?

This Photo by Unknown Author is licensed under CC BY

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

 A tree consists of a root, a number of branches leaving the root, and


possible additional branches leaving the endpoints of other branches.
 To use trees in counting, we use a branch to represent each possible
choice. We represent the possible outcomes by the leaves, which are the
endpoints of branches not having other branches starting at them

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?

This Photo by Unknown Author is licensed under CC BY-SA


18
5. Tree Diagrams

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

 A permutation 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.
 The number of r-permutations of a set with n elements is denoted by
P(n, r).
 We can find P(n, r) using the product rule.

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

Counting permutations when repetition of elements is allowed can easily


be done using the product rule.

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

 An r-combination 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.

 The number of r-combinations of a set with n distinct elements is


𝑛
denoted by C(n, r). Note that C(n, r) is also denoted by and is called
𝑟
a binomial coefficient

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

C(9, 3) ⋅ C(11, 4) = 9! ⋅ 11!


3!6! 4!7!
= 84 ⋅ 330 = 27,720.
34
Combinations with Repetition

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

The solution is the number of 4-combinations with repetition allowed from a


three-element set, {apple, orange, pear}.
35
Combinations with Repetition

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

Consider of three sets A, B, and C.

Count of elements by

|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩


C|.
45
Principle Of Inclusion–
Exclusion For Three Set
Example :
A total of 1232 students have taken a course in Spanish, 879 have taken a
course in French, and 114 have taken a course in Russian. Further, 103 have
taken courses in both Spanish and French, 23 have taken courses in both
Spanish and Russian, and 14 have taken courses in both French and
Russian. If 2092 students have taken at least one of Spanish, French, and
Russian, how many students have taken a course in all three languages?
Solution :
Let
S : set of students who have taken a course in Spanish,
F : the set of students who have taken a course in French, and
R : the set of students who have taken a course in Russian.

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.

When we insert these quantities into the equation


|S ∪ F ∪ R| = |S| + |F| + |R| − |S ∩ F| − |S ∩ R| − |F ∩ R| + |S ∩ F ∩
R|
we obtain
2092 = 1232 + 879 + 114 − 103 − 23 − 14 + |S ∩ F ∩ R|.
We now solve for |S ∩ F ∩ R|.
We find that |S ∩ F ∩ R| = 7.
Therefore, there are seven students who have taken courses in
Spanish, French, and Russian
47
Principle Of Inclusion–
Exclusion For Three Set

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:

a. From the binomial theorem it follows that

51
The Binomial Theorem

Solution :

b. By the binomial theorem, we Have

Consequently, the coefficient of 𝑥 12 𝑦 13 in the expansion is obtained when j =


13, namely,

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

Pascal’s identity is the basis for a geometric arrangement of the binomial


coefficients in a triangle. The nth row in the triangle consists of the binomial
coefficients

This triangle is known as Pascal’s triangle, named after the French mathematician Blaise
Pascal
54
Pascal’s triangle

55
Reference

Kenneth H. Rosen, “ Discrete Mathematics and its


Applications”, 8th edition,219, McGraw-Hill Education,
New York, ISBN 978-1-259-67651-2

56
Thank You

You might also like