CSCE 235
Handout
18: Counting
Assigned March 3, 2004
Principle of Inclusion-Exclusion
Given
a finite number of finite sets,
, the number of elements in the union
is
![]()
Some readers may notice that the problems discussed so far could also have been solved by Venn diagrams, which are an acceptable approach wherever possible. When more than three sets are involved, however, Venn diagrams can no longer be used.
Example
Of 30 personal computers (PCs) owned by faculty members in a certain university department, 20 run Windows, 8 have 21 inch monitors, 25 have CD-ROM drives, 20 have at least two of these features, and 6 have all three.
(a) How many PCs have at least one of these features?
(b) How many have none of these features?
(c) How many have exactly one feature?
Let W = { the
set of PCs running under Windows }, M = { set of PCs with 21 inch
monitors }, and C = { the set with CD-ROM drives }. We are given that
,
,
,
(“20 have at least
two of these features”), and
(“6 have all
three”). Now, we have set up the
problem. Now, what do we do? How do we proceed? The first strategy is to locate the unions. Out of the five sets, only
is a union. Why do we look for unions? This is because we can break a union down to
a sum using the Principle of Inclusion-Exclusion. By the Principle of Inclusion-Exclusion,
.
Now, we can simplify
the above equation. How?
,
,
, and
. So, the above
equation can be simplified to:
![]()
Now, the above equation
is a bit familiar! We know that
. Thus, we have
. So,
. Since we do not
have any more unions to break down, we are ready to attempt to answer the three
questions.
(a) The number of PCs with at least one feature is

(b) How many have none of these features? Since there are 27 PCs with at least one feature, then there are 30 – 7 = 3 PCs that have none of these features.
(c) How many have exactly one feature? We know that the number of PCs with at least one feature is 27. We know that the number of PCs with at least two features is 20 (given). Thus, the number of PCs with exactly one feature is simply 27 – 20 = 7.
Principle of Inclusion-Exclusion (Disjoint Sets)
Given
n pairwise disjoint finite sets,
, then
![]()
This principle allows us to have the addition rule and the multiplication rule.
Addition Rule (Sum Rule)
The number of ways in which precisely one of a collection of mutually exclusive events can occur is the sum of the number of ways in which each event can occur (basically the above).
If
a first task can be done in
ways and a second
task in
ways, and if these
tasks cannot be done at the same time, then there are
ways to do one of
these tasks
Example
In how many ways can you get a total of six when rolling two dice?
The event “get a six”
is the union of the following mutually exclusive subevents:
= { two 3s },
= { a 2 and a 4 },
and
= { a 1 and a 5
}. Are these subevents mutually
exclusive, i.e., disjoint? Yes! That means we can use the principle of
inclusion-exclusion (disjoint sets) and the addition rule. So,
. Now, we need to
find out the size of each set:
,
,
. Thus, there are
1+2+2 = 5 ways to get a total of six when rolling two dice.
Multiplication Rule (Product Rule)
The number of ways in which a sequence of events can occur is the product of the number of ways in which each individual event can occur.
(a) For finite sets
, we have
![]()
(b) More generally, suppose that a given set can
be viewed as a set of ordered k-tuples
with the following
structure. There are
possible choices of
; given
, there are
possible choices of
; and so on. So, the
set has
elements. We can use this to count cards.
Suppose
that a procedure can be broken down into a sequence of two tasks. If there are
ways to do the first
task and
ways to do the second
task after the first task has been done, then there are
ways to do the
procedure.
Example
A license plate of a Nebraska vehicle has 3 digits and 3 letters. For example, NYZ 123. However, the first letter is always the letter ‘N’. Suppose the other letters can range between ‘A’ and ‘Z’, and each of the last three digits can range between 0 and 9, how many unique license plates can the state of Nebraska issue?
In this case, we have
six sets:
= { first letter: ‘N’
},
= { second letter:
‘A’ through ‘Z’ },
= { third letter: ‘A’
through ‘Z’ },
= { 1st digit after
letter: 0 to 9 },
= { 2nd digit after
letter: 0 to 9 }, and
= { 3rd
digit after letter: 0 to 9 }. Are these
sets mutually exclusive, i.e., disjoint?
Yes! Once again, that means we
can use the principle of inclusion-exclusion (disjoint sets) and the
multiplication rule. So,
. We know that
. We know the size of the alphabet is 26,
. And we know that
. Thus, there are
(1)(26)(26)(10)(10)(10) = 676,000 unique license plates that can be issued by
the state. By the way, does that mean
that the state of Nebraska expect only 676,000 cars registered within the
state? What about vanity plates?
The Pigeon-Hole Principle
If n objects are put into m boxes and n > m, then at least one box contains two or more of the objects.
The Pigeon-Hole Principle (Strong Form)
If n objects are
put into m boxes and n > m, then some box must contain at
least
objects.
Example
In a classroom of 60 students, at least how many students will have birthdays in one of the months of a year?
There are twelve months
in a year. In this case, we have 60
students that we want to put into these 12 boxes. So, n = 60 and m = 12. So, n > m.
So, now we can invoke the Pigeon-Hole Principle. Thus, at least
= 60/12 = 5 students
will have birthdays in one of the months.
Based on (Rosen
2004), (Ross and Wright 1988) and (Goodaire and Parmenter 2002).