L08-Counting Principle
L08-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.
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
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|
•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