Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

R.

Johnsonbaugh
Discrete Mathematics
5
th
edition, 2001
Chapter 4
Counting methods
and the pigeonhole principle
4.1 Basic principles
Multiplication principle
If an activity can be performed in k
successive steps,
Step 1 can be done in n
1
ways
Step 2 can be done in n
2
ways

Step k can be done in n
k
ways
Then: the number of different ways that the
activity can be performed is the product
n
1
n
2
n
k
Addition principle
Let X
1
, X
2
,, X
k
be a collection of k
pairwise disjoint sets, each of which has n
j

elements, 1 < j < k, then the union of
those sets

k
X = X
j

j =1
has n
1
+ n
2
+ + n
k
elements
4.2 Permutations and combinations
A permutation of n distinct elements x
1
, x
2
,, x
n

is an ordering of the n elements. There are n!
permutations of n elements.

Example: there are 3! = 6 permutations of three
elements a, b, c:
abc bac cab
acb bca cba
r-permutations
An r-permutation of n distinct elements is an
ordering of an r-element subset of the n
elements x
1
, x
2
,, x
n

Theorem 4.2.10:
For r < n the number of r-permutations of a set
with n distinct objects is
P(n,r) = n(n-1)(n-2)(n-r+1) = n !/(n-r) !
If r = n, P(n,n) = n !


Combinations
Let X = {x
1
, x
2
,, x
n
} be a set containing n
distinct elements
An r-combination of X is an unordered
selection of r elements of X, for r < n
The number of r-combinations of X is the
binomial coefficient

C(n,r) = = n! / r!(n-r)! = P(n,r)/ r!
Catalan numbers
Eugene-Charles Catalan (1814-1894)
Catalan numbers are defined by the formula
C
n
= C(2n,n) / (n+1)
for n = 0, 1, 2,
The first few terms are:

n 0 1 2 3 4 5 6 7 8 9 10
C
n
1 1 2 5 14 42 132 429 1430 4862 16796
4.3 Algorithms for generating
permutations and combinations
Lexicographic order:
Given two strings o = s
1
s
2
s
p
and | = t
1
t
2
t
q
Define o < | if
p < q and s
i
= t
i
for all i = 1, 2,, p
Or for some i, s
i
= t
i
and for the smallest i, s
i
< t
i


Example: if o = 1324, | = 1332, = 132,
then < o and o < |.
4.4 Introduction to
discrete probability
An experiment is a process that yields an
outcome

An event is an outcome or a set of outcomes
from an experiment

The sample space is the event of all possible
outcomes
Probability
Probability of an event is the number of
outcomes in the event divided by the number of
outcomes in the sample space.

If S is a finite sample space and E is an event
(E is a subset of S) then the probability of E is

P(E) = |E| / |S|
4.5 Discrete probability theory
When all outcomes are equally likely and
there are n possible outcomes, each one
has a probability 1/n.

BUT this is not always the case. When
all probabilities are not equal, then some
probability (possibly different numbers)
must be assigned to each outcome.
Probability function
A probability function P is a function from
the set of all outcomes (sample space S) to
the interval [0, 1], in symbols
P : S [0, 1]

The probability of an event E _ S is the sum
of the probabilities of every outcome in E
P(E) = E P(x)

x e E


Probability of an event
Given E _ S, we have
0 < P(E) < P(S) = 1
If S = {x
1
, x
2
,, x
n
} is a sample space, then

n
P(S) = E P(x
i
) = 1
i =1

If E
c
is the complement of E in S, then
P(E) + P(E
c
) = 1
Events in a sample space
Given any two events E
1
and E
2
in a sample
space S. Then
P(E
1
E
2
) = P(E
1
) + P(E
2
) P(E
1
E
2
)

We also have P(C) = 0

Events E
1
and E
2
are mutually exclusive if and
only if E
1
E
2
= C. In this case
P(E
1
E
2
) = P(E
1
) + P(E
2
)

Conditional probability
Conditional probability is the probability of an
event E, given that another event F has
occurred, is called. In symbols P(E|F).
If P(F) > 0 then
P(E|F) = P(EF) / P(F)
Two events E and F are independent if
P(EF) = P(E)P(F)
Pattern recognition
Pattern recognition places items into classes,
based on various features of the items.
Given a set of features F we can calculate the
probability of a class C, given F: P(C|F)
Place the item into the most probable class, i.e.
the one C for which P(C|F) is the highest.
Example: Wine can be classified as Table wine (T), Premium (R)
or Swill (S). Let F e {acidity, body, color, price}
Suppose a wine has feature F, and P(T|F) = 0.5, P(R|F) = 0.2
and P(S|F) = 0.3. Since P(T|F) is the highest number, this wine
will be classified as table wine.
Bayes Theorem
Given pairwise disjoint classes C
1
, C
2
,,
C
n
and a feature set F, then
P(C
j
|F) = A / B, where

A = P(F|C
j
)P(C
j
)

n
and B = E P(F|C
i
)P(C
i
)

i = 1

Generalized permutations
and combinations
Theorem 4.6.2: Suppose that a sequence of n
items has n
j
identical objects of type j,
for 1< j < k. Then the number of orderings of S
is
____n!____
n
1
!n
2
!...n
k
!
4.7 Binomial coefficients
and combinatorial identities
Theorem 4.7.1: Binomial theorem. For any real
numbers a, b, and a nonnegative integer n:
(a+b)
n
= C(n,0)a
n
b
0
+ C(n,1)a
n-1
b
1
+
+ C(n,n-1)a
1
b
n-1
+ C(n,n)a
0
b
n
n
(a+b)
n
= E C(n,k) a
n-k
b
k


k = 0



Theorem 4.7.6: For 1 < k < n,
C(n+1,k) = C(n,k) + C(n,k-1) and
n
E C(i,k) = C(n+1,k+1)

i = k


Pascals Triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1

4.8 The pigeonhole principle
First form: If k < n and n pigeons fly into k
pigeonholes, some pigeonhole contains at least
two pigeons.
Second form of the
pigeonhole principle
If X and Y are finite sets with |X| > |Y| and
f : X Y is a function, then f(x
1
) = f(x
2
) for
some x
1
, x
2
e X, x
1
= x
2
.

Third form of the
pigeonhole principle
If X and Y are finite sets with |X| = n, |Y| = m
and k = n/m(, then there are at least k values
a
1
, a
2
,, a
k
e X such that f(a
1
) = f(a
2
) = f(a
k
).

Example:
n = 5, m = 3
k = n/m( = 5/3( = 2.

You might also like