0% found this document useful (0 votes)
34 views

L08-Counting Principle

the counting principles

Uploaded by

kelvin baisy
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

L08-Counting Principle

the counting principles

Uploaded by

kelvin baisy
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Counting principle

L-8

1
•The sum rule:
•If a task can be done in n1 ways and a second task in
n2 ways, and if these two tasks cannot be done at the
same time, then there are n1 + n2 ways to do either
task.
•Example:
•The department will award a free computer to either
a CS student or a CS professor. How many different
choices are there, if there are 530 students and 15
professors?
•There are 530 + 15 = 545 choices. 2
•Generalized sum rule:
• If we have tasks T1, T2, …, Tm that can
be done in n1, n2, …, nm ways,
respectively, and no two of these tasks
can be done at the same time, then
there are n1 + n2 + … + nm ways to do
one of these tasks. 3
•The product rule:
•Suppose that a procedure can be broken
down into two successive tasks. If there
are n1 ways to do the first task and n2 ways
to do the second task after the first task
has been done, then there are n1n2 ways
to do the procedure.

4
•Example:
•How many different license plates are there that
containing exactly three English letters ?
Solution:
•There are 26 possibilities to pick the first letter, then
26 possibilities for the second one, and 26 for the last
one.

•So there are 262626 = 17576 different license plates.


5
• Try
1. 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)?
2 The Telephone Numbering Plan The North American numbering plan (NANP) specifies the
format of telephone numbers in the U.S., Canada, and many other parts of North America. A
telephone number in this plan consists of 10 digits, which are split into a three-digit area code, a
three-digit office code, and a four-digit station code. Because of signaling considerations, there
are certain restrictions on some of these digits. To specify the allowable format, let X denote a
digit that can take any of the values 0 through 9, let N denote a digit that can take any of the
values 2 through 9, and let Y denote a digit that must be a 0 or a 1. Two numbering plans, which
will be called the old plan, and the new plan, will be discussed. (The old plan, in use in the 1960s,
has been replaced by the new plan, but the recent rapid growth in demand for new numbers for
mobile phones and devices will eventually make even this new plan obsolete. In this example,
the letters used to represent digits follow the conventions of the North American Numbering
Plan.) As will be shown, the new plan allows the use of more numbers. In the old plan, the
formats of the area code, office code, and station code are NYX, NNX, and XXXX, respectively, so
that telephone numbers had the form NYX-NNX-XXXX. In the new plan, the formats of these
codes are NXX, NXX, and XXXX, respectively, so that telephone numbers have the form NXX-NXX-
XXXX. How many different North American telephone numbers are possible under the old plan
and under the new plan? 6
•Generalized product rule:
•If we have a procedure consisting of
sequential tasks T1, T2, …, Tm that can be done
in n1, n2, …, nm ways, respectively, then there
are n1  n2  …  nm ways to carry out the
procedure.
7
Permutation

8
Permutation
• Example -A school musical director can select 2 musical plays to
present next year. One will be presented in the fall, and one will be
presented in the spring. If she has 9 to pick from, how many different
possibilities are there?

9
Permutation
• TRY
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?
2. In how many ways can 4 people be arranged
in a row for a photo?
10
Arrangements with Repetitions
• If we have n elements of which x are alike of one kind, y are alike of
another kind, z are alike of another kind, ............ then the number of
ordered selections or permutations is given by:

11
• Example
• How many different arrangements of the word PARRAMATTA are
possible?

12
Combinations

• A selection of distinct objects without regard to order is called a


combination.

• The difference between a permutation and a combination is that in a


combination, the order or arrangement of the objects is not
important; by contrast, order is important in a permutation.
• Permutations are for lists (order matters) and combinations are for
groups (order doesn't matter).

• How many different committees of three students can be formed


from a group of four students?
•  13
14
We see that C(4, 2) = 6, because the 2-combinations of {a, b, c, d} are the six subsets
{a, b},{a, c}, {a, d}, {b, c}, {b, d}, and {c, d}.
 
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?
15
•Example:
•A soccer club has 8 female and 7 male members. For
today’s match, the coach wants to have 6 female and 5
male players on the grass. How many possible
configurations are there?

•C(8, 6)  C(7, 5) = 8!/(6!2!)  7!/(5!2!)


• = 2821
• = 588
16
The Principle of Inclusion-Exclusion
Example .How many bit strings of length 8 either start with a 1 or end
with 00?
•Task 1: Construct a string of length 8 that starts with a 1.
•There is one way to pick the first bit (1),
•two ways to pick the second bit (0 or 1),
•two ways to pick the third bit (0 or 1),
.
.
.
•two ways to pick the eighth bit (0 or 1).
•Product rule: Task 1 can be done in 127 = 128 ways.
17
The Principle of Inclusion-Exclusion

•Task 2: Construct a string of length 8 that ends with 00.


•There are two ways to pick the first bit (0 or 1),
•two ways to pick the second bit (0 or 1),
.
.
.
•two ways to pick the sixth bit (0 or 1),
•one way to pick the seventh bit (0), and
•one way to pick the eighth bit (0).
•Product rule: Task 2 can be done in 26 = 64 ways.

18
The Principle of Inclusion-Exclusion

•Since there are 128 ways to do Task 1 and 64 ways to do Task 2, does
this mean that there are 192 bit strings either starting with 1 or ending
with 00 ?
•No, because here Task 1 and Task 2 can be done at the same time.
•When we carry out Task 1 and create strings starting with 1, some of
these strings end with 00.
•Therefore, we sometimes do Tasks 1 and 2 at the same time, so the
sum rule does not apply.

19
The Principle of Inclusion-Exclusion
•If we want to use the sum rule in such a case, we have to subtract the
cases when Tasks 1 and 2 are done at the same time.
•How many cases are there, that is, how many strings start with 1 and
end with 00?
•There is one way to pick the first bit (1),
•two ways for the second, …, sixth bit (0 or 1),
•one way for the seventh, eighth bit (0).
•Product rule: In 25 = 32 cases, Tasks 1 and 2 are carried out at the
same time.

20
The Principle of Inclusion-Exclusion
•Since there are 128 ways to complete Task 1 and 64 ways to complete
Task 2, and in 32 of these cases Tasks 1 and 2 are completed at the
same time, there are
128 + 64 – 32 = 160 ways to do either task.

•In set theory, this corresponds to sets A1 and A2 that are not disjoint.
Then we have:
|A1  A2| = |A1| + |A2| - |A1  A2|

•This is called the principle of inclusion-exclusion.


21
The Principle of Inclusion-Exclusion
EXAMPLE
• In a discrete mathematics class every student is a
major in computer science or mathematics, or both.
The number of students having computer science as a
major (possibly along with mathematics) is 25; the
number of students having mathematics as a major
(possibly along with computer science) is 13; and the
number of students majoring in both computer science
and mathematics is 8. How many students are in this
class?
22
The Principle of Inclusion-Exclusion
• Solution: Let A be the set of students in the class majoring in
computer science and B be the set of students in the class
majoring in mathematics. Then A n B is the set of students in the
class who are joint mathematics and computer science majors.
Because every student in the class is majoring in either computer
science or mathematics (or both), it follows that the number of
students in the class is I A U B I . Therefore,

•I A U B I = I A I + I B I - I A n B I
• = 25 + 13 - 8
• = 30.
• Therefore, there are 30 students in the class.
23
The Principle of Inclusion-Exclusion
• How many positive integers not exceeding 1 000 are divisible by 7 or
11 ?

24
25
26
• TRY
• 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?
• 
27
• END

28

You might also like