Slide 8 - Counting
Slide 8 - Counting
Slide 8 - Counting
1
Every extraordinary feet began in ordinary circumstances. I will start my journey of success from where I am now.
License
2
References
Discrete Mathematics and its Applications by Kenneth H. Rosen
• Chapter 6 : Counting
3
Why?
To solve different types of problem
• Counting is used to determine the complexity of algorithms.
• Counting is also required to determine whether there are enough
telephone numbers or Internet protocol addresses to meet demand.
• Recently, it has played a key role in mathematical biology, especially in
sequencing DNA.
• Furthermore, counting techniques are used extensively when
probabilities of events are computed.
4
Basic Counting Principles: THE SUM RULE
Sum Rule: If no two events can occur at the same time, then one of the events can
occur in: n1+n2+n3+···ways.
Sum Rule Principle: Suppose A and B are disjoint sets. Then n(A∪B) = n(A) + n(B)
5
Basic Counting Principles: THE SUM RULE
Sum Rule: If no two events can occur at the same time, then one of the events can
occur in: n1+n2+n3+···ways.
Sum Rule Principle: Suppose A and B are disjoint sets. Then n(A∪B) = n(A) + n(B)
6
Basic Counting Principles: THE SUM RULE
Sum Rule: If no two events can occur at the same time, then one of the events can
occur in: n1+n2+n3+···ways.
Sum Rule Principle: Suppose A and B are disjoint sets. Then n(A∪B) = n(A) + n(B)
7
The Sum Rule : Example
Problem : 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.
8
The Sum Rule : Example
Problem : Suppose a college has 3 different history courses, 4 different literature courses,
and 2 different sociology courses. What is the number of ways a student can choose just one
of the courses?
Solution:
9
The Sum Rule : Example
Problem :
Solution:
10
Basic Counting Principles: THE PRODUCT
RULE
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 n1.n2 ways to do the
procedure.
Product Rule: If the events occur one after the other, then all the events can occur
in the order indicated in: n1·n2·n3·...ways.
Product Rule Principle: Let A × B be the Cartesian product of sets A and B. Then
n(A×B) = n(A) · n(B)
11
Basic Counting Principles: THE PRODUCT
RULE
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 n1.n2 ways to do the
procedure.
Product Rule: If the events occur one after the other, then all the events can occur
in the order indicated in: n1·n2·n3·...ways.
Product Rule Principle: Let A × B be the Cartesian product of sets A and B. Then
n(A×B) = n(A) · n(B)
12
Basic Counting Principles: THE PRODUCT
RULE
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 n1.n2 ways to do the
procedure.
Product Rule: If the events occur one after the other, then all the events can occur
in the order indicated in: n1·n2·n3·...ways.
Product Rule Principle: Let A × B be the Cartesian product of sets A and B. Then
n(A×B) = n(A) · n(B)
13
The Product Rule : Example
Problem : 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)?
Solution: There are 26 choices for each of the three uppercase English letters and
ten 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.
14
The Product Rule : Example
Problem : Suppose a college has 3 different history courses, 4 different literature courses,
and 2 different sociology courses. What is the number of ways a student can choose just one
of each kind of courses?
Solution:
15
The Product Rule : Example
Problem : How many functions are there from a set with m elements to a set with
n elements?
16
The Product Rule : Example
Problem : There are 32 microcomputers in a computer center. Each microcomputer
has 24 ports. How many different ports to a microcomputer in the center are there?
Solution: The procedure of choosing a port consists of two tasks, first picking a
microcomputer and then picking a port on this microcomputer. Because there are 32
ways to choose the microcomputer and 24 ways to choose the port no matter which
microcomputer has been selected, the product rule shows that there are 32·24=768
ports.:
17
The Product Rule : Example
Problem : A new company with just two employees, Aowal and Ajoy, rents a floor of a
building with 12 offices. How many ways are there to assign different offices to these two
employees?
Solution: The procedure of assigning offices to these two employees consists of
assigning an office to Koni, which can be done in 12 ways, then assigning an office
to Nadira different from the office assigned to Koni, which can be done in 11 ways.
By the product rule, there are 12·11 = 132 ways to assign offices to these two
employees.
18
The Product Rule : Example
Problem : How many different bit strings of length seven are there?
Solution: Each of the seven bits can be chosen in two ways, because each bit is
either 0 or 1. Therefore, the product rule shows there are a total of 2^7=128
different bit strings of length seven.
19
The Product Rule : Example
Problem :
Solution:
20
The Subtraction Rule (Inclusion–Exclusion for Two
Sets)
Theorem
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.
21
The Subtraction Rule : Example
Problem : A computer company receives 350 applications from computer 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 be the set of students who majored in computer science and A2 the set of
students who majored in business. Then A1∪A2 is the set of students who majored in
computer science or business (or both), and A1∩A2 is the set of students who majored both in
computer science and in business. By the subtraction rule the number of students who
majored either in computer science or in business (or both) equals
|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.
22
The Subtraction Rule : Example
Problem : How many bit strings of length eight either start with a 1 bit or end with
the two bits 00?
Solution:
23
The Division Rule
Theorem
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 do f then ways correspond
to way w.
24
The Division Rule: Example
Problem : How many different ways are there to seat four people around
a circular table, where two seating's are considered the same when each
person has the same left neighbor and the same right neighbor?
Solution:
25
Tree Diagram
• How many bit strings of length four do not have two consecutive 1s?
26
Tree Diagram
• Suppose that “I Love New Jersey” T-shirts come in five different sizes: S, M, L,
XL, and XXL. Further suppose that each size comes in four colors, white, red,
green, and black, except for XL, which comes only in red, green, and black, and
XXL, which comes only in green and black. How many different shirts does a
souvenir shop have to stock to have at least one of each available size and
color of the T-shirt?
27
Tree Diagram
• Suppose that “I Love New Jersey” T-shirts come in five different sizes: S, M, L,
XL, and XXL. Further suppose that each size comes in four colors, white, red,
green, and black, except for XL, which comes only in red, green, and black, and
XXL, which comes only in green and black. How many different shirts does a
souvenir shop have to stock to have at least one of each available size and
color of the T-shirt?
28
How do you Learn?
Problem
A history class contains 8 male students and 6 female students. Find the
number of ways that the class can elect:
(a) 1 class representative;
(b) 2 class representatives, 1 male and 1 female;
(c) 1 president and 1 vice president.
29
The Pigeonhole Principle
30
The Pigeonhole Principle
Theorem
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.
31
The Pigeonhole Principle
Theorem
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.
32
The Pigeonhole Principle
Example
• Suppose a department contains 13 professors, then two of the professors
(pigeons) were born in the same month (pigeonholes)
• Among any group of 367 people, there must be at least two with the same
birthday, because there are only 366 possible birthdays.
33
The Pigeonhole Principle
Example
• Suppose a department contains 13 professors, then two of the professors
(pigeons) were born in the same month (pigeonholes)
• Among any group of 367 people, there must be at least two with the same
birthday, because there are only 366 possible birthdays.
34
The Pigeonhole Principle
Example
• Among any group of 367 people, there must be at least two with the same
birthday, because there are only 366 possible birthdays.
• 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.
35
The Generalized Pigeonhole Principle
Theorem
If N objects are placed into k boxes, then there is at least one box containing at least
[N/k] objects.
36
The Generalized Pigeonhole Principle
Example
• Among 100 people there are at least 100/12=9 who were born in the same month.
• What is the minimum number of students required in a discrete mathematics class to
be sure that at least six will receive the same grade, if there are five possible grades, A,
B, C, D, and F?
Solution: The minimum number of students needed to ensure that at least six students
receive the same grade is the smallest integer N such thatN/5=6. The smallest such
integer is N=5·5+1=26. If you have only 25 students, it is possible for there to be five who
have received each grade so that no six students have received the same grade. Thus, 26
is the minimum number of students needed to ensure that at least six students will
receive the same grade.
37
The Generalized Pigeonhole Principle
Example
• What is the minimum number of students required in a discrete mathematics class to
be sure that at least six will receive the same grade, if there are five possible grades, A,
B, C, D, and F?
Solution: The minimum number of students needed to ensure that at least six students
receive the same grade is the smallest integer N such that N/5=6. The smallest such
integer is N=5·5+1=26. If you have only 25 students, it is possible for there to be five who
have received each grade so that no six students have received the same grade. Thus, 26
is the minimum number of students needed to ensure that at least six students will
receive the same grade.
38
Problem!!!
• In how many ways can we arrange five students in a line for a picture?
• In how many ways can we select three students from a group of five
students to stand in line for a picture?
39
Permutations
Theorem
Any arrangement of a set of n objects in a given order is called a permutation of the
object (taken all at a time).
40
Permutations
Theorem
Any arrangement of a set of n objects in a given order is called a permutation of the
object (taken all at a time).
41
Permutations
Theorem
Any arrangement of a set of n objects in a given order is called a permutation of the
object (taken all at a time).
Corollary
There are n! permutations of n objects (taken all at a time).
42
r-permutation
Theorem
Any arrangement of any r ≤ n of n objects in a given order is called an “r-permutation” or
“a permutation of then objects taken r at a time.”
43
r-permutation
Theorem
Any arrangement of any r ≤ n of n objects in a given order is called an “r-permutation” or
“a permutation of then objects taken r at a time.”
44
r-permutation
• In how many ways can we select three students from a group of five students to stand in
line for a picture?
• In how many ways can we select four students from a group of five students to stand in
line for a picture
45
r-permutation
Theorem
46
P (n, r) = n(n−1)(n−2)···(n−r+1)
Proof
We will use the product rule to prove that this formula is correct. The first element of
the permutation can be chosen in n ways because there are n elements in the set. There
are n−1 ways to choose the second element of the permutation, because there aren−1
elements left in the set after using the element picked for the first position. Similarly,
there are n−2 ways to choose the third element, and so on, until there are exactly n−
(r−1)=n−r+1 ways to choose the rth element. Consequently, by the product rule, there are
n(n−1)(n−2)···(n−r+1) r-permutations of the set.
47
r-permutation
Theorem
48
r-permutation
COROLLARY
49
r-permutation : Example
Problem: 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?
Solve: 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.
50
r-permutation : Example
Problem: Suppose that there are eight runners in a race. The winner receives a gold medal, the
second place finisher receives a silver medal, and the third-place finisher receives a bronze medal.
How many different ways are there to award these medals, if all possible outcomes of the race can
occur and there are no ties?
Solve: The number of different ways to award the medals is the number of 3-
permutations of a set with eight elements. Hence, there are
P(8,3) = 8·7·6 = 336 possible ways to award the medals.
51
r-permutation : Example
Problem: How many permutations of the letters ABCDEFGH contain the string
ABC?
Solve: Because the letters ABC must occur as a block, we can find the answer by finding
the number of permutations of six objects, namely, the block ABC and the individual
letters D, E, F, G, and H. Because these six objects can occur in any order, there are 6!
=720 permutations of the letters ABCDEFGH in which ABC occurs as a block.
52
Permutations with Repetitions
53
Permutations with Repetitions
Theorem
54
Permutations with Repetitions:
Example
55
Permutations with Repetitions:
Example
• Find the number of seven-letter words that can be formed using the
letters of the word “BENZENE.”
56
Again Problem!!!
57
r-combination
Theorem
Let S be a set with n elements. A combination of these n elements taken r at a time is
any selection of r of the elements where order does not count.
Such a selection is called an r-combination; it is simply a subset of S with r elements. The
number of such combinations will be denoted by
58
r-combination : Example
Problem: Find the number of combinations of 4 objects A,B,C,D, taken 3 at a
time.
Solve:
59
r-combination
Theorem
60
r-combination
• How many ways are there to select five players from a 10-member
tennis team to make a trip to a match at another school?
• 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)?
61
The Binomial Theorem
Theorem
62
The Binomial Theorem
Solve:
63
The Binomial Theorem
Solve:
64
Pascal’s Identity and Triangle
Theorem
65
Pascal’s Identity and Triangle
66