You are on page 1of 21

Lecture 7

Counting
 To apply Sum and product Rule in solving problems.
 To apply Inclusion-exclusion Principle
 To apply Pigeonhole Principle
Sum Rule/Addition Rule The Sum Rule says that,
 If there are methods to complete
a task.

𝑤1  For the first method, , there are


different ways to be done.
 For the Second method, , there
𝑀2 𝑤2 are different ways to be done.

Tas  For the method, , there are


different ways to be done.
k  For the last method, , there are
… different ways to be done.

𝑤𝑛
The total different ways to
complete the task
+
Example 1:
Everyday, there are 2 trains routine, 5 express
bus routine, and 4 flight routine from Malaysia
to Singapore. How many different ways can a
passenger travel from Malaysia to Singapore?
Train

Total
Bus
different
5 ways
11
Fligh
t
4
Sum Rule/Addition Rule
 Suppose a finite set A equals the union of k distinct
mutually disjoint subsets . Then

 In
general, the Sum Rule can be written as:
Number of total different ways a task can be done
Example 2:

A student wants to borrow a book from


library. He can choose the book from 3
business books, 5 computer science books,
and 2 mathematics books. How many
different ways he can borrow the book from
library?

3 + 5 + 2 = 10 different ways to borrow a


books.
Product Rule
 Ifa task needs n steps to complete it.
Step 1 consists of ways, step 2 consists
of ways, … ,and step n consists of
ways, then the total different ways to
complete the task is

Step 1, Step 2, … Step n,


Product rule
If John travel from town A to town C via
town B. There are 3 routes from town A to
town B and 2 routes from town B to town
C. In how many ways can John travel
from town A to town C?
Town C
Town A

Town B
Product rule

Jane has 5 different shirts and 4 different


jeans, how many different combination she
can dress those shirts and jeans?

Solution:
Jane needs 2 steps to complete this task.
Step 1: Choose a shirt. 5 different ways
Step 2: Choose a pair of jean. 4 different
ways
Exercise:
1. In how many ways can the word
“Computing” can be arranged?
2. In how many ways can 3 persons be
seated in an empty bus that has 44 seats.
Sum and Product rule

Each of five cards contain digit 0, 1, 2, 3, 4


respectively.
1. In how many ways these cards can be arranged to
get an odd number if repetitions are not allowed?
2. In how many ways these cards can be arranged to
obtain a number that is greater than 30,000 if
repetition not allowed..
3. In how many ways these cards can be arranged to
obtain an odd number that is greater than 30,000
if repetition is not allowed?
Inclusion-Exclusion Principle
For Two Sets

11
Inclusion-Exclusion Principle
For Three Sets

12
Inclusion-Exclusion Principle
Generally

13
Example 3
Scenario:
Out of 50 students in a class
◦ 30 took precalculus
◦ 18 took calculus
◦ 26 took Java
◦ 9 took both precalculus and calculus
◦ 16 took both precalculus and Java
◦ 8 took both calculus and Java
◦ 47 took at least one of the three courses.
Example 3
Questions:
a. How many students did not take any of the
three courses?
b. How many students took all three courses?
c. How many students took precalculus and
calculus but not Java? How many students
took precalculus but neither calculus nor
Java?
Example 3
Solutions:
a. 50-47=3
b. Let,
Example 3
Solutions:
c. Refer to diagram…
The Pigeonhole Principle
Ifm pigeons are put into n holes, where , at least
two pigeons must be in the same hole.
Also known as the Dirichlet Drawer Principle or
the Shoe Box Principle

18
Example 1
A drawer contains ten black and ten white socks.
What is the least number of socks to pull out to
be sure to get a matched pair?

3 Socks
Example 2
Let
a. If five integers are selected from A, must at least
one pair of the integers have a sum of 9?
b. If four integers are selected from A, must at least
one pair of the integers have a sum of 9?

Answers:
• Partition the set into the following
disjoint subsets having a sum of 9.
{1,8}, {2,7}, {3,6} and {4,5}

a. YES
b. NO
The End

You might also like