Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Counting

• Counting of object help us solve many


different types of problems.
• In Computer Science, it is used to determine
the complexity of algorithm.
The Basics of Counting
The Product Rule
• It is applied when a procedure is made up
of separate tasks.

• 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.
Examples
• How many different bit strings of length
seven are there?
• How many different license plates are
available if each plate contains a sequence
of three letters followed by three digits (and
no sequence of letters are prohibited, even
if they are obscene)?
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.
Examples
• Suppose that either a member of the
mathematics faculty or a student who is a
mathematics major is chosen a s a
representative to a University committee.
How many different choices are there for
this representative if there are 37 members
of the mathematics faculty and 83
mathematics majors and no one is both a
faculty member and a student?
• A student 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?
• In a version of the BASIC, the name of a
variable is a string of one or two alphanumeric
characters, where uppercase and lower case
letters are the same. Moreover, a variable
name must begin with a letter and must be
different from the five strings of two characters
for reserved words. How many different variable
names are there in this version?
The Inclusion-Exclusion Principle
• This happens when some tasks in n1 are the same
tasks in n2.
|A1∪ A2| = |A1| + |A2| - |A1∩ A2|

• A computer company receives 350 applicants from


computer graduates for a job planning line of new
Web servers. Suppose that 220 of these people
majored in computer science, 147 majored in
business, and 51 majored in both in CS and
business. How many of these applicants majored
neither in CS nor in business?
Exercises
• There are 18 mathematics majors and 325
computer science majors at a college.
o How many ways are there to pick two
representatives so that one is
mathematics major and the other is a
computer science major?
o How many ways are there to pick one
representative who is either a
mathematics major or a computer
science major?
• A multiple-choice test contains ten
questions. There are four possible answers for
each question.
o How many ways can a student answer
the questions on the test if the student
answer every question?
o How many ways can a student answer
the questions on the test if the student
can leave answers blank?
• How many different three-letter initials can
people have?
• How many bit strings are there of length
eight?
• How many strings are there of lowercase
letters of length four or less?
• In how many ways can a photographer at a
wedding arrange 6 people in a row of 10
people, where the bride and the groom are
among these 10 people, if
o the bride must be in the picture?
o both the bride and the groom must be in the
picture?
The Pigeonhole Principle
Theorem 1
• The Pigeonhole Principle
o 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.
Examples
• Among any group of 367 people, there must
be at least two with the same birth date,
because there are only 365 or 366 (for leap
year) possible birth dates.
• 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?
o 102 students
Theorem 2
• The Generalized Pigeonhole Principle
o If N objects are place into k boxes, then there is
at least one box containing at least ‫𝑁ڿ‬/𝑘‫ۀ‬
objects.
• Examples:
o Among 100 people there are at least ‫ڿ‬100/12‫ = ۀ‬9
who were born in the same month.
o 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 grades, A, B, C, D and F?
Exercises
• Show that if any seven numbers from 1 to 12
are chosen, then two of them will add to 13.
• How many numbers must be selected from
the set {1, 2, 3, 4, 5, 6} to guarantee that at
least one pair of these numbers add up to
7?
• Show that if seven colors are used to paint
50 bicycles, at least eight bicycles must
have the same colors.
• A company stores products in a warehouse.
Storage bins in this warehouse are specified
by their aisle, location in the aisle, and shelf.
There are 50 aisles, 85 horizontal locations in
each aisle, and 5 shelves throughout the
warehouse. What is the least number of
products the company can have so that at
least two products must be stored in the
same bin?
Permutation
• Each different arrangement or ordered set
of objects is called a permutation of those
objects.
• Theorem 1. The total number of
permutations of n objects taken r at a time,
P(n, r), is given by the expression,
P(n, r) = n(n – 1)(n – 2)∙∙∙ (𝑛 − 𝑟 + 1)
𝑛!
P(n, r) =
𝑛 −𝑟 !
Examples
• Find the number of permutations of the four
integers 1, 2, 3, 4 taken two at a time.
P(4,2) = 4 ∙ 𝟑 = 𝟏𝟐
• If four persons enter a bus in which there are
ten vacant seats, how many ways are there
for the four to be seated?
P(10,4) = 10∙ 𝟗 ∙ 𝟖 ∙ 𝟕 = 𝟓𝟎𝟒𝟎
• In how many ways may five books be
arranged taken five at a time?
P(5,5) = 5! = 120
• Theorem 2. If P represents the number of
different permutations of n things taken at a
time, when p are of one kind, q are of
another kind, r of third kind, and so on, then
𝑛!
P=
𝑝!𝑞!𝑟!
• How many permutations are there of the 11
letters in “Mississippi” taken all together?
11!
P= = 34,650 ; there are 4 s’s, 4 i’s and 2 p’s
4!4!2!
Exercises
1. How many number of three different digits
each can be formed from the digits 1, 2, 3,
4, 5, 6, 7, 8, 9?
2. How many number of three different digits
each less than 700 can be formed from the
digits in the above problem?
3. In how many ways can four boys and four
girls be seated in a row containing seven
seats.
a. If they may seat anywhere,
b. If the boys and girls must alternate.
5. A baseball manager insists on having his
best hitter bath fourth and the pitcher bat
last. In such circumstances, how many
batting orders are possible?
6. In how many ways can eight people be
seated around a table?
Combinations
• It is a set or collection of objects in no
particular order.
• Theorem 1. The total number of
combinations of n objects taken r at a time,
C(n,r), is given by the expression

C(n,r) = n!
(n − r )! r!
C(n,r) = C(n, n - r)
Examples
1. Compute C(15,12)
o C(15,12) = C(15,(15 - 12)) = C(15,3) =
15! 15! 15 14 13 = 455
= =
(15 − 3)!3! 12!3! 3  2 1
2. In a class of 15 boys and 10 girls, in how
many ways may a committee made up
of 3 boys and 2 girls be selected?
15! 10! 15 14 13 10  9
C (15,3) C (10,2) =  =  = 20,475
(15 − 3)!3! (10 − 2)2! 1 2  3 1 2
Exercises
1. Find the value of
a. C(7,4) b. C(21,19)
2. In how many ways may a committee of 4
be chosen from a group of 25?
3. From a group of 25 Democrats and 18
Republicans, how many committees
consisting of 3 Democrats and 2
Republicans are possible?
4. On a college baseball squad, there are
three catchers, five pitchers, seven
infielders, and seven outfielders. How many
different baseball nines can be formed?
5. A committee of 5 people is to be chosen
from a group of 6 men and 4 women. How
many committees are possible if:
a. There are no restrictions?
b. One particular person must be chosen on
the committee?
c. There are to be 3 men and 2 women?
d. There are to be men only?
e. There is to be a majority of women?
End of Presentation
Sources:
Epp, Susanna S. (2011). Discrete Mathematics
With Applications, Fourth Edition.
Brooks/Cole Cengage Learning

Haggard, Gary, John Schlipf, and Sue Whitesides


(2009). Discrete Mathematics for Engineers
and Scientists, Cengage Learning Asia Pte
Ltd.

Rosen, Kenneth H. (2008). Discrete Mathematics


and its Application, 6th ed. McGraw Hill.

You might also like