Counting Principles

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

CHAPTER 5

Counting

5.1. Basic Principles

5.1.1. The Rule of Sum. If a task can be performed in m ways,


while another task can be performed in n ways, and the two tasks
cannot be performed simultaneously, then performing either task can
be accomplished in m + n ways.
Set theoretical version of the rule of sum: If A and B are disjoint
sets (A B = ) then
|A B| = |A| + |B| .
More generally, if the sets A1 , A2 , . . . , An are pairwise disjoint, then:
|A1 A2 An | = |A1 | + |A2 | + + |An | .

For instance, if a class has 30 male students and 25 female students,


then the class has 30 + 25 = 45 students.

5.1.2. The Rule of Product. If a task can be performed in m


ways and another independent task can be performed in n ways, then
the combination of both tasks can be performed in mn ways.
Set theoretical version of the rule of product: Let A B be the
Cartesian product of sets A and B. Then:
|A B| = |A| |B| .
More generally:
|A1 A2 An | = |A1 | |A2 | |An | .

For instance, assume that a license plate contains two letters fol-
lowed by three digits. How many different license plates can be printed?
Answer : each letter can be printed in 26 ways, and each digit can be
printed in 10 ways, so 26 26 10 10 10 = 676000 different plates can
be printed.
69
5.1. BASIC PRINCIPLES 70

Exercise: Given a set A with m elements and a set B with n ele-


ments, find the number of functions from A to B.

5.1.3. The Inclusion-Exclusion Principle. The inclusion-exclusion


principle generalizes the rule of sum to non-disjoint sets.
In general, for arbitrary (but finite) sets A, B:
|A B| = |A| + |B| |A B| .

Example: Assume that in a university with 1000 students, 200 stu-


dents are taking a course in mathematics, 300 are taking a course in
physics, and 50 students are taking both. How many students are
taking at least one of those courses?
Answer : If U = total set of students in the university, M = set
of students taking Mathematics, P = set of students taking Physics,
then:
|M P | = |M | + |P | |M P | = 300 + 200 50 = 450
students are taking Mathematics or Physics.
For three sets the following formula applies:
|A B C| =
|A| + |B| + |C| |A B| |A C| |B C| + |A B C| ,
and for an arbitrary union of sets:
|A1 A2 An | = s1 s2 + s3 s4 + sn ,
where sk = sum of the cardinalities of all possible k-fold intersections
of the given sets.
5.2. COMBINATORICS 71

5.2. Combinatorics

5.2.1. Permutations. Assume that we have n objects. Any ar-


rangement of any k of these objects in a given order is called a per-
mutation of size k. If k = n then we call it just a permutation of the
n objects. For instance, the permutations of the letters a, b, c are the
following: abc, acb, bac, bca, cab, cba. The permutations of size 2 of
the letters a, b, c, d are: ab, ac, ad, ba, bc, bd, ca, cb, cd, da, db, dc.
Note that the order is important. Given two permutations, they
are considered equal if they have the same elements arranged in the
same order.
We find the number P (n, k) of permutations of size k of n given
objects in the following way: The first object in an arrangement can
be chosen in n ways, the second one in n 1 ways, the third one in
n 2 ways, and so on, hence:
(k factors) n!
P (n, k) = n (n 1) (n k + 1) = ,
(n k)!
(n factors)
where n! = 1 2 3 n is called n factorial .
The number P (n, k) of permutations of n objects is

P (n, n) = n! .

By convention 0! = 1.
For instance, there are 3! = 6 permutations of the 3 letters a, b, c.
The number of permutations of size 2 of the 4 letters a, b, c, d is P (4, 2) =
4 3 = 12.
Exercise: Given a set A with m elements and a set B with n ele-
ments, find the number of one-to-one functions from A to B.

5.2.2. Combinations. Assume that we have a set A with n ob-


jects. Any subset of A of size r is called a combination of n ele-
ments taken r at a time. For instance, the combinations of the letters
a, b, c, d, e taken 3 at a time are: abc, abd, abe, acd, ace, ade, bcd, bce,
bde, cde, where two combinations are considered identical if they have
the same elements regardless of their order.
5.2. COMBINATORICS 72

The number of subsets of size r in a set A with n elements is:


n!
C(n, r) = .
r! (n r)!

The symbol nr (read n choose r) is often used instead of C(n, r).

One way to derive the formula for C(n, r) is the following. Let A
be a set with n objects. In order to generate all possible permutations
of size r of the elements of A we 1) take all possible subsets of size
r in the set A, and 2) permute the k elements in each subset in all
possible ways. Task 1) can be performed in C(n, r) ways, and task
2) can be performed in P (r, r) ways. By the product rule we have
P (n, r) = C(n, r) P (r, r), hence
P (n, r) n!
C(n, r) = = .
P (r, r) r! (n r)!

You might also like