0% found this document useful (0 votes)
52 views

Lecture Notes in Discrete Mathematics - Part 6

This document contains lecture notes on discrete mathematics and the analysis of algorithms. It discusses several topics: 1. Elements of counting including the inclusion-exclusion principle and the addition rule for counting elements in pairwise disjoint sets. 2. Fundamentals of probability theory including sample spaces, events, mutually exclusive and exhaustive events, and basic probability rules. 3. Asymptotic analysis including big-O, Θ, and Ω notations to describe the asymptotic behavior of algorithms. Examples are provided to illustrate these concepts.

Uploaded by

Moch Dedy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Lecture Notes in Discrete Mathematics - Part 6

This document contains lecture notes on discrete mathematics and the analysis of algorithms. It discusses several topics: 1. Elements of counting including the inclusion-exclusion principle and the addition rule for counting elements in pairwise disjoint sets. 2. Fundamentals of probability theory including sample spaces, events, mutually exclusive and exhaustive events, and basic probability rules. 3. Asymptotic analysis including big-O, Θ, and Ω notations to describe the asymptotic behavior of algorithms. Examples are provided to illustrate these concepts.

Uploaded by

Moch Dedy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Lecture Notes in Discrete Mathematics

Marcel B. Finan
Arkansas Tech University
All
c Rights Reserved
166 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS

It follows that n! = O(nn ).


b. We show by induction on n ≥ 0 that n ≤ 2n .

Basis of induction: For n = 0 we have 0 ≤ 20 .


Induction hypothesis: Suppose that n ≤ 2n .
Induction step: We must show that n + 1 ≤ 2n+1 . Indeed,

n+1 ≤n+n
≤ 2n + 2n = 2n+1

Hence, n = O(2n ).
c. Take the logarithm of both sides of b. to obtain log2 n ≤ n, n ≥ 1. That
is, log2 n = O(n).

Example 29.3
a. Show that log2 n! = O(n log2 n).
b. Show that n log2 n = O(log2 n!).

Solution.
a. We have shown that n! = O(nn ). That is, n! ≤ nn for n ≥ 1. Take loga-
rithm of both sides to obtain log2 n! ≤ n log2 n. That is, log2 n! = O(n log2 n).
b. It is easy to see that (n − i)(i + 1) ≥ n for all 0 ≤ i ≤ n − 1. In this case

(n!)2 = [n · (n − 1) · · · 2 · 1][1 · 2 · · · (n − 1) · n]
= (n · 1)[(n − 1) · 2] · · · [2 · (n − 1)](1 · n)
≥ n · n···n · n
= nn .

Now take the logarithm of both sides to obtain n log2 n ≤ 2 log2 n!. That is,
n log2 n = O(log2 n!).

Example 29.4
a. Show that if f1 (n) ∈ O(g(n)) and f2 (n) ∈ O(g(n)) then f1 (n) + f2 (n) ∈
O(g(n)).
b. Show that if f1 (n) ∈ O(g1 (n)) and f2 (n) ∈ O(g2 (n)) then f1 (n) · f2 (n) ∈
O(g1 (n) · g2 (n)).
c. Use a. and b. to show that

3n log2 n! + (n2 + 3) log2 n = O(n2 log2 n).


29 LOGARITHMIC AND EXPONENTIAL COMPLEXITIES 167

Solution.
a. Since f1 (n) ∈ O(g(n)) then there exist n1 and C1 such that |f1 (n)| ≤
C1 |g(n)| for all n ≥ n1 . Similarly, there exist constants C2 and n2 such that
|f2 (n)| ≤ C2 |g(n)| for all n ≥ n2 . Let n0 = max{n1 , n2 } and C = C1 + C2 .
Then for n ≥ n0 we have

|f1 (n) + f2 (n)| ≤ C1 |g(n)| + C2 |g(n)| = C|g(n)|.

b. Now since f1 (n) ∈ O(g1 (n)), there exist n1 and C1 such that |f1 (n)| ≤
C1 |g1 (n)| for all n ≥ n1 . Similarly, there exist constants C2 and n2 such that
|f2 (n)| ≤ C2 |g2 (n)| for all n ≥ n2 . Let n0 = max{n1 , n2 } and C = C1 · C2 .
Then for n ≥ n0 we have

|f1 (n) · f2 (n)| ≤ C|g1 (n)g2 (n)|.

c. Using b. above and a. of the previous exercise we have 3n log2 n! =


O(n2 log2 n). Since (n2 + 3) log2 n = O(n2 log2 n) then by a. and b. the result
follows.
168 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS

Review Problems
Problem 29.1
Show that 1 + 2 + 22 + · · · + 2n ∈ O(2n+1 ).

Problem 29.2
Show that 2n
3
+ 2n
32
+ 2n
33
+ ··· + 2n
3n
∈ O(n).

Problem 29.3
Show that n2 + 2n ∈ O(2n ).

Problem 29.4
a. Show that 21 + 13 + · · · + n1 ≤ ln n, n ≥ 2.
b. Use part a. to show that for n ≥ 3
1 1
1+ + · · · + ≤ ln n.
2 n
n n n
c. Use b. to show that n + 2
+ 3
+ ··· + n
∈ O(n ln n).

Problem 29.5
Show that 2n ∈ O(n!).
30 Θ- AND Ω-NOTATIONS 169

30 Θ- and Ω-Notations
The O-notation asymptotically bounds a function from above. When we
have bounds from above and below, we use Θ notation. For a given function
g(n), we denote by Θ(g(n)) to be the set of all functions f such that there
exist positive constants C1 , C2 , and n0 such that C1 |g(n)| ≤ |f (n)| ≤ C2 |g(n)|
for all n ≥ n0 . If f ∈ Θ(g(n)) we write f (n) = Θ(g(n)).

Example 30.1
Show that 21 n2 − 3n = Θ(n2 ).

Solution.
Let C1 and C2 be positive constants such that
1
C1 n2 ≤ n2 − 3n ≤ C2 n2 .
2
This is equivalent to
1 3
C1 ≤ − ≤ C2 .
2 n
Since 21 − n3 ≤ 12 for all n ≥ 1, we choose C2 ≥ 12 . Since 1
2
− 3
n
≥ 1
4
for all
n ≥ 12, we choose C1 ≤ 14 . Finally, we choose n0 = 12.

Example 30.2
Show that 6n3 6= Θ(n2 ).

Solution.
We use the argument by contradiction. Suppose that 6n3 = Θ(n2 ). Then
there exist positive constants C1 , C2 and n0 such that

C1 n2 ≤ 6n3 ≤ C2 n2

for all n ≥ n0 . The right-hand side inequality yields 6n ≤ C2 for n ≥ n0 .


This says that the left-hand side can be made as large as we want whereas
the right-hand side is fixed. A contradiction.

Theorem 30.1
For given two functions f (n) and g(n), f (n) = Θ(g(n)) if and only if f (n) =
O(g(n)) and g(n) = O(f (n)).
170 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS

Proof.
Suppose that f (n) = Θ(g(n)). Then there exist positive constants C1 , C2 ,
and n0 such that C1 |g(n)| ≤ |f (n)| ≤ C2 |g(n)| for all n ≥ n0 . The left-hand
side inequality implies that g(n) = O(f (n)) whereas the right-hand side in-
equality implies that f (n) = O(g(n)). Now go backward for the converse.

Just as O provides an asymptotic upper bound on a function, Ω−notation


provides an asymptotic lower bound. For a given function g(n), let Ω(g(n))
denote the set of all funtions f (n) such that there exist positive constants
C and n0 such that C|g(n)| ≤ |f (n)| for all n ≥ n0 . For f (n) ∈ Ω(g(n)) we
write f (n) = Ω(g(n)).

Example 30.3
Show that log2 n! = Ω(n log2 n).

Solution.
Since (n!)2 ≥ nn for all n ≥ 1 we find n log2 n ≤ 2 log2 n!. That is, 21 n log2 n ≤
log2 n! for n ≥ 1. This says that log2 n! = Ω(n log2 n).

Theorem 30.2
For given two functions f (n) and g(n), f (n) = Θ(g(n)) if and only if f (n) =
O(g(n)) and f (n) = Ω(g(n)).

Proof.
Suppose first that f (n) = Θ(g(n)). Then there exist positive constants C1 , C2
and n0 such that C1 |g(n)| ≤ |f (n)| ≤ C2 |g(n)| for n ≥ n0 . The right-hand
side inequality implies that f (n) = O(g(n)) whereas the left-hand side in-
equality implies that f (n) = Ω(g(n)).
Conversely, suppose that f (n) = O(g(n)) and f (n) = Ω(g(n)). Then there
exist constants C1 , C2 , n1 and n2 such that |f (n)| ≤ C2 |g(n)| for n ≥ n2 and
C1 |g(n)| ≤ |f (n)| for n ≥ n1 . Let n0 = max{n1 , n2 }. Then for n ≥ n0 we
have C1 |g(n)| ≤ |f (n)| ≤ C2 |g(n)|. That is, f (n) = Θ(g(n)).

Example 30.4
Let f (n) and g(n) be two given functions. We say that f (n) = o(g(n)) if and
only if limn→∞ fg(n)
(n)
= 0.
a. Show that if f (n) = o(g(n)) then f (n) = O(g(n)).
b. Find two functions f (n) and g(n) such that f (n) = O(g(n) but f (n) 6=
o(g(n)).
30 Θ- AND Ω-NOTATIONS 171

Solution.
a. Suppose that f (n) = o(g(n)). Then there is a positive integer n0 such
that | fg(n)
(n)
| ≤ 1 for n ≥ n0 . That is, |f (n)| ≤ |g(n)| for all n ≥ n0 . Hence,
f (n) = O(g(n)).
b. Let f (n) = 2n2 and g(n) = n2 .
172 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
Fundamentals of Counting and
Probability Theory

The major goal of this chapter is to establish several techniques for counting
large finite sets without actually listing their elements. Also, the fundamen-
tals of probablity theory are discussed.

31 Elements of Counting
For a set X, |X| denotes the number of elements of X. It is easy to see that
for any two sets A and B we have the following result known as the Inclu-
sion - Exclusion Principle

|A ∪ B| = |A| + |B| − |A ∩ B|.


Indeed, |A| gives the number of elements in A including those that are com-
mon to A and B. The same holds for |B|. Hence, |A| + |B| includes twice
the number of common elements. Hence, to get an accurate count of the
elements of A ∪ B, it is necessary to subtract |A ∩ B| from |A| + |B|.
Note that if A and B are disjoint then |A ∩ B| = 0 and consequently
|A ∪ B| = |A| + |B|.

Example 31.1 (The Addition Rule)


Show by induction on n, that if {A1 , A2 , · · · , An } is a collection of pairwise
disjoint sets then

|A1 ∪ A2 ∪ · · · ∪ An | = |A1 | + |A2 | + · · · + |An |.

Solution.
Basis of induction: For n = 2 the result holds by the Inclusion-Exclusion

173
174 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Principle.
Induction hypothesis: Suppose that for any collection {A1 , A2 , · · · , An } of
pairwise disjoint sets we have

|A1 ∪ A2 ∪ · · · ∪ An | = |A1 | + |A2 | + · · · + |An |.

Induction step: Let {A1 , A2 , · · · , An , An+1 } be a collection of pairwise disjoint


sets. Since (A1 ∪ A2 ∪ · · · ∪ An ) ∩ An+1 = (A1 ∩ An+1 ) ∪ · · · ∪ (An ∩ An+1 ) = ∅
then by the Inclusion-Exclusion Principle and the induction hypothesis we
have

|A1 ∪ A2 ∪ · · · ∪ An ∪ An+1 | = |A1 ∪ A2 ∪ · · · ∪ An | + |An+1 |


= |A1 | + |A2 | + · · · + |An | + |An |

Example 31.2
A total of 35 programmers interviewed for a job; 25 knew FORTRAN, 28
knew PASCAL, and 2 knew neither languages. How many knew both lan-
guages?

Solution.
Let A be the group of programmers that knew FORTRAN, B those who
knew PASCAL. Then A ∩ B is the group of programmers who knew both
languages. By the Inclusion-Exclusion Principle we have

|A ∪ B| = |A| + |B| − |A ∩ B|.

That is,
33 = 25 + 28 − |A ∩ B|.
Solving for |A ∩ B| we find |A ∩ B| = 20.
Another important rule of counting is the multiplication rule. It states
that if a decision consists of k steps, where the first step can be made in n1
different ways, the second step in n2 ways, · · · , the kth step in nk ways, then
the decision itself can be made in n1 n2 · · · nk ways.

Example 31.3
a. How many possible outcomes are there if 2 distinguishable dice are rolled?
b. Suppose that a state’s license plates consist of 3 letters followed by four
digits. How many different plates can be manufactured? (no repetitions)
31 ELEMENTS OF COUNTING 175

Solution.
a. By the multiplication rule there are 6 × 6 = 36 possible outcomes.
b. By the multiplication rule there are 26 × 25 × 24 × 10 × 9 × 8 × 7 possible
license plates.
Example 31.4
Let Σ = {a, b, c, d} be an alphabet with 4 letters. Let Σ2 be the set of all
words of length 2 with letters from Σ. Find the number of all words of length
2 where the letters are not repeated. First use the product rule. List the
words by means of a tree diagram.
Solution.
By the multiplication rule there are 4 × 3 = 12 different words. Constructing
a tree diagram

we find that the words are


{ab, ac, ad, ba, bc, bd, ca, cb, cd, da, db, dc}

An r-permutation of n objects, in symbol P (n, r), is an ordered selection


of r objects from a given n objects.
Example 31.5
n!
a. Use the product rule to show that P (n, r) = (n−r)! .
b. Find all possible 2-permutations of the set {1, 2, 3}.
Solution.
a. We can treat a permutation as a decision with r steps. The first step
can be made in n different ways, the second in n − 1 different ways, ...,
the rth in n − r + 1 different ways. Thus, by the multiplication rule there
are n(n − 1) · · · (n − r + 1) r-permutations of n objects. That is, P (n, r) =
n!
n(n − 1) · · · (n − r + 1) = (n−r)! .
3!
b. P (3, 2) = (3−2)! = 6.
176 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Example 31.6
How many license plates are there that start with three letters followed by 4
digits (no repetitions)?

Solution.
P (26, 3) · P (10, 4) = 78, 624, 000.

An r-combination of n objects, in symbol C(n, r), is an unordered selec-


tion of r of the n objects. Thus, C(n, r) is the number of ways of choosing
r objects from n given objects without taking order in account. But the
number of different ways that r objects can be ordered is r!. Since there are
C(n, r) groups of r objects from a given n objects then the number of ordered
selection of r objects from n given objects is r!C(n, r) = P (n, r). Thus

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

Example 31.7
In how many different ways can a hand of 5 cards be selected from a deck of
52 cards?(no repetition)

Solution.
C(52, 5) = 2, 598, 960.

Example 31.8
Prove the following identities:
a. C(n, 0) = C(n, n) = 1 and C(n, 1) = C(n, n − 1) = n.
b. Symmetry property: C(n, r) = C(n, n − r), r ≤ n.
c. Pascal’s identity: C(n + 1, k) = C(n, k − 1) + C(n, k), n ≥ k.

Solution.
a. Follows immediately from the definition of of C(n, r).
b. Indeed, we have
n!
C(n, n − r) = (n−r)!(n−n+r)!
n!
= r!(n−r)!
= C(n, r)
31 ELEMENTS OF COUNTING 177

c.
n! n!
C(n, k − 1) + C(n, k) = (k−1)!(n−k+1)!
+ k!(n−k)!
= n!k
k!(n−k+1)!
+ n!(n−k+1)
k!(n−k)!
n!
= k!(n−k+1)!
(k + n − k + 1)
(n+1)!
= (n+1−k)!
= C(n + 1, k)

Pascal’s identity allows one to construct the following triangle known as


Pascal’s triangle (for n = 5) as follows
1
1 → 1
1 → 2 → 1
1 → 3 → 3 →1
1 → 4 → 6 →4 → 1
The following theorem provides an expension of (x + y)n where n is a non-
negative integer.

Theorem 31.1 (Binomial Theorem)


Let x and y be variables, and let n be a positive integer. Then
n
X
n
(x + y) = C(n, k)xn−k y k
k=0

where C(n, k) is called the binomial coefficient.

Proof.
The proof is by induction.

Basis of induction: For n = 1 we have


1
X
1
(x + y) = C(1, k)x1−k y k = x + y.
k=0

Induction hypothesis: Suppose that the theorem is true for n.


Induction step: Let us show that it is still true for n + 1. That is
n+1
X
n+1
(x + y) = C(n + 1, k)xn−k+1 y k .
k=0
178 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Indeed, we have

(x + y)n+1 = (x + y)(x + y)n = x(x + y)n + y(x + y)n


Xn Xn
n−k k
= x C(n, k)x y + y C(n, k)xn−k y k
k=0 k=0
n
X n
X
= C(n, k)xn−k+1 y k + C(n, k)xn−k y k+1
k=0 k=0
n+1
= C(n, 0)x + C(n, 1)x y + C(n, 2)xn−1 y 2
n

+ · · · + C(n, n)xy n + C(n, 0)xn y


+ C(n, 1)xn−1 y 2 + · · · + C(n, n − 1)xy n
+ C(n, n)y n+1
= C(n + 1, 0)xn+1 + C(n + 1, 1)xn y + C(n + 1, 2)xn−1 y 2
+ · · · + C(n + 1, n)xy n + C(n + 1, n + 1)y n+1
n+1
X
= C(n + 1, k)xn−k+1 y k .
k=0

Example 31.9
Expand (x + y)6 using the binomial theorem.

Solution.
By the Binomial Theorem and Pascal’s triangle we have

(x + y)6 = x6 + 6x5 y + 15x4 y 2 + 20x3 y 3 + 15x2 y 4 + 6xy 5 + y 6

Example 31.10
a. Show that Pnk=0 C(n, k) = 2n .
P
b. Show that nk=0 (−1)k C(n, k) = 0.

Solution.
a. Letting x = y = 1 in the binomial theorem we find
n
X
n n
2 = (1 + 1) = C(n, k).
k=0

b. This follows from the binomial theorem by letting x = 1 and y = −1


31 ELEMENTS OF COUNTING 179

Review Problems

Problem 31.1
a. How many ways can we get a sum of 4 or a sum of 8 when two distin-
guishable dice are rolled?
b. How many ways can we get a sum of 8 when two undistinguishable dice
are rolled?

Problem 31.2
a. How many 4-digit numbers can be formed using the digits, 1, 2, · · · , 9
(with repetitions)? How many can be formed if no digit can be repeated?
b. How many different license plates are there that involve 1, 2, or 3 letters
followed by 4 digits (with repetitions)?

Problem 31.3
a. In how many ways can 4 cards be drawn, with replacement, from a deck
of 52 cards?
b. In how many ways can 4 cards be drawn, without replacement, from a
deck of 52 cards?

Problem 31.4
In how many ways can 7 women and 3 men be arranged in a row if the three
men must always stand next to each other.

Problem 31.5
A menu in a Chinese restaurant allows you to order exactly two of eight
main dishes as part of the dinner special. How many different combinations
of main dishes could you order?

Problem 31.6
Find the coefficient of a5 b7 in the binomial expansion of (1 − 2b)12 .

Problem 31.7
Use the binomial theorem to prove that
n
X
n
3 = 2k C(n, k).
k=0
180 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

32 Basic Probability Terms and Rules


Probability theory is one of the serious branch of mathematics with applica-
tions to many sciences, namely the theory of statistics. This section intro-
duces the most basic ideas of probabiltiy.
An experiment is any operation whose outcomes cannot be predicted with
certainty. The sample space S of an experiment is the set of all possible
outcomes for the experiment. For example, if you roll a die one time then
the experiment is the roll of the die. A sample space for this experiment is
S = {1, 2, 3, 4, 5, 6} where each digit represents a face of the die.
An event is any subset of a sample space. Thus, if S is the sample space
then the collection of all possible events is the power set P(S).
The Probability of an event E is the measure of occurrence of E. It is a
number between 0 and 1. If the event is impossible to occur then its proba-
bility is 0. If the occurrence is certain then the probability is 1. The closer
to 1 the probability is, the more likely the event is. The probability of oc-
currence of an event E (called its success) will be denoted by P (E). Thus,
0 ≤ P (E) ≤ 1. If an event has no outcomes, that is as a subset of S if E = ∅
then P (∅) = 0. On the other hand, if E = S then P (S) = 1.

Example 32.1
Which of the following numbers cannot be the probability of some event? (a)
0.71 (b)−0.5 (c) 150% (d) 34 .

Solution.
(a) Yes. (b) No. Since the number is negative. (c) No since the number is
greater than 1. (d) No.

Various probability concepts exist nowadays. The classical probability con-


cept applies only when all possible outcomes are equally likely, in which
case we use the formula
number of outcomes f avorable to event |E|
P (E) = = ,
total number of outcomes |S|
where |E| is the number of elements in E.

Example 32.2
What is the probability of drawing an ace from a well-shufled deck of 52
playing cards?
32 BASIC PROBABILITY TERMS AND RULES 181

Solution.
4 1
P (Ace) = 52 = 13
.

Example 32.3
What is the probability of rolling a 3 or a 4 with a fair die?

Solution.
2
P (3 or 4) = 6
= 31 .

A major shortcoming of the classical probability concept is its limited applica-


bility, for there are many situations in which the various outcomes cannot
all regarded as equally likely. This would be the case, for instance, when
we wonder whether a person will get a raise or when we want to predict the
outcome of an election. A widely used probability concept is the estimated
probability which uses the relative frequency of an event and is given by the
formula:
f
P (E) = Relative f requency = ,
n
where f is the frequency of the event and n is the size of the sample space.

Example 32.4
Records show (over a period of time) that 468 of 600 jets from Dallas to
Phoenix arrived on time. Estimate the probability that any one jet from
Dallas to Phoenix will arrive on time.

Solution.
P (E) = nf = 468
600
= 39
50

We define the probability of nonoccurrence of an event E (called its fail-


ure) by the formula
P (E c ) = 1 − P (E).
Note that
P (E) + P (E c ) = 1.

Example 32.5
The probability that a college student without a flu shot will get the flu is
0.45. What is the probability that a college student without the flu shot will
not get the flu?
182 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Solution.
The probability is 1 − 0.45 = .55.

Next, we discuss some of the rules of probability. The union of two events
A and B is the event A ∪ B whose outcomes are either in A or in B. The
intersection of two events A and B is the event A ∩ B whose outcomes
are outcomes of both events A and B. Two events A and B are said to be
mutually exclusive if they have no outcomes in common. In this case
A ∩ B = ∅.

Example 32.6
If A and B are mutually exclusive then what is P (A ∩ B)?

Solution.
P (∅) = 0.

Theorem 32.1
For any events A and B the probability of A ∪ B is given by the addition
rule
P (A ∪ B) = P (A) + P (B) − P (A ∩ B).
If A and B are mutually exclusive then by Exercise 443 the above formula
reduces to
P (A ∪ B) = P (A) + P (B).

Proof.
By the Inclusion-Inclusion Principle we have

|A ∪ B| = |A| + |B| − |A ∩ B|.

Thus,
|A∪B|
P (A ∪ B) = |S|
|A| |B|
= |S|
+ |S|
− |A∩B|
|S|
= P (A) + P (B) − P (A ∩ B).

Example 32.7 P
For any event E of a sample space S show that P (E) = x∈E P (x).

Solution.
This follows from the previous theorem
32 BASIC PROBABILITY TERMS AND RULES 183

Example 32.8
M &M plain candies come in a variety of colors. According to the manufac-
turer, the color distribution is:
(a) Orange: 15% (b) Green: 10% (c) Red: 20% (d) Yellow: 20% (e)
Brown: 30% (f) Tan: 5%.
Suppose you have a large bag of plain candies and you reach in and take one
candy at random. Find
1. P(orange candy Or tan candy). Are these outcomes mutually exclusive?

2. P(not brown candy).

Solution.
1. P(orange candy Or tan candy) = .15 + .05 = .2 = 20%. The outcomes
are mutually exclusive.
2. P(not brown candy) = 1 − .3 = .7 = 70%

Example 32.9
If A is the event ”drawing an ace” from a deck of cards and B is the event
”drawing a spade”. Are A and B mutually exclusive? Find P (A ∪ B).

Solution.
The events are not mutually exclusive since there is an ace that is also a
spade.
4 13 1
P (A ∪ B) = P (A) + P (B) − P (A ∩ B) = + − = 31%
13 52 52

Now, given two events A and B belonging to the same sample space S.
The conditional probability P (A|B) denotes the probability that event A
will occur given that event B has occurred. It is given by the formula
P (A ∩ B)
P (A|B) = .
P (B)

Example 32.10
Consider the experiment of tossing two dice. What is the probability that
the sum of two dice equals six given that the first die is a four?
184 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Solution.
The possible outcomes of our experiment are
{(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)}.
Thus, the probability that the sum is six given that the first die is four is 16 .
Assuming that the experiment consists of tossing the two dice then by letting
B be the event that the first die is 4 and A be the even that the sum of the
two dice is 6 then
1
P (A ∩ B) 36 1
P (A|B) = = 6 =
P (B) 36
6

If P (A|B) = P (A), we say that the two events A and B are independent.
That is, the occurrence of A is independent whether or not B occurs. If two
events are not independent, we say that they are dependent.
Example 32.11
Show that A and B are independent if and only if
P (A ∩ B) = P (A) · P (B).
Solution.
Suppose that A and B are independent. Then P (A) = P (A|B) = P P(A∩B) (B)
.
That is, P (A ∩ B) = P (A) · P (B). Conversely, if P (A ∩ B) = P (A) · P (B)
then P (A|B) = P P(A∩B)
(B)
= P (A).
Example 32.12
You roll two fair dice: a green one and a red one.
a. Are the outcomes on the dice independent?
b. Find P(5 on green die and 3 on red die).
c. Find P(3 on green die and 5 on red die).
d. Find P((5 on green die and 3 on red die) or (3 on green die and 5 on red
die)).
Solution.
a. Yes.
b. P(5 on green die and 3 on red die) = 16 · 16 = 36
1
.
1
c. P(3 on green die and 5 on red die) = 36 .
d. P((5 on green die and 3 on red die) or (3 on green die and 5 on red die))
1 1 1
= 36 + 36 = 18 .
32 BASIC PROBABILITY TERMS AND RULES 185

Example 32.13
Show that
P (B) · P (A|B)
P (B|A) = .
P (A)
Solution.
This follows from the fact that P (A ∩ B) = P (B ∩ A) and the formula of
P (A|B) given above.

Example 32.14
Prove Bayes’ Theorem
P (B|A)P (A)
P (A|B) = .
P (B|A)P (A) + P (B|Ac )P (Ac )
Solution.
Note first that {Ac ∩ B, A ∩ B} form a partition of B. Thus,

P (B) = P (A ∩ B) + P (Ac ∩ B).

Now by the previous exercise we have


P (A)·P (B|A)
P (A|B) = P (B)
P (B|A)P (A)
= P (B|A)P (A)+P (B|Ac )P (Ac )

Example 32.15
Consider two urns. The first contains two white and seven black balls and
the second contains five white and six black balls. We flip a fair coin and
then draw a ball from the first urn or the second urn depending on whether
the outcome was head or tail. What is the conditional probability that the
outcome of the toss was head given that a white ball was selected?

Solution.
Let W be the event that a white ball is drawn, and let H be the event that
the coin comes up heads. The desired probability P (H|W ) may be calculated
as follows:
P (H∩W )
P (H|W ) = P (W )
P (W |H)P (H)
= P (W )
P (W |H)P (H)
= P (W |H)P (H)+P (W |H c )P (H c )
2 1
22
= 21
9 2
5 1
+ 11
= 67
92 2
186 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

It frequently occurs that in performing an experiment we are mainly inter-


ested in some functions of the outcome as opposed to the outcome itself. For
example, in tossing dice we are interested in the sum of the dice and are not
really concerned about the actual outcome. These real-valued functions de-
fined on the sample space are known as random variables. If the range is
a finite subset of IN then the random variable is called discrete. Otherwise,
the random variable is said to be continuous. Discrete random variable are
usually the result of a count whereas a continuous random variable is usually
the result of a measurement.
A probability distribution is a correspondence that assigns probabilities
to the values of a random variable. The graph of a probability distribution
is called is a histogram.

Example 32.16
Let f denote the random variable that is defined as the sum of two fair dice.
Find the probability distribution of f.

Solution.
1
P (f = 2) = P ({(1, 1)}) = 36 ,
2
P (f = 3) = P ({(1, 2), (2, 1)}) = 36 ,
3
P (f = 4) = P ({(1, 3), (2, 2), (3, 1)}) = 36 ,
4
P (f = 5) = P ({(1, 4), (2, 3), (3, 2), (4, 1)}) = 36 ,
5
P (f = 6) = P ({(1, 5, (5, 1), (2, 4), (4, 2), (3, 3)}) = 36 ,
6
P (f = 7) = P ({(1, 6), (6, 1), (2, 5), (5, 2), (4, 3), (3, 4)}) = 36
,
5
P (f = 8) = P ({(2, 6), (6, 2), (3, 5), (5, 3), (4, 4)}) = 36 ,
4
P (f = 9) = P ({(3, 6), (6, 3), (4, 5), (5, 4)}) = 36 ,
3
P (f = 10) = P ({(4, 5), (5, 4), (5, 5)}) = 36 ,
2
P (f = 11) = P ({(5, 6), (6, 5)}) = 36 ,
1
P (f = 12) = P ({(6, 6)}) = 36 .

Example 32.17
Construct the histogram of the random variable of the previous exercise.
32 BASIC PROBABILITY TERMS AND RULES 187

Solution.

For a discrete random variable f we define the expected value ( or mean)


of f by the formula
X
E(f ) = f (x)P (x)
x∈S

In other words, E(f ) is a weighted average of the possible values that f can
take on, each value being weighted by the probability that f assumes that
value.

Example 32.18
Find E(f ) where f is the outcome when we roll a fair die.

Solution.
1
Since P (1) = P (2) = · · · = P (6) = 6
we find

1 1 1 7
E(f ) = 1( ) + 2( ) + · · · + 6( ) =
6 6 6 2
188 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Another quantity of interest is the variance of a random variable f , de-


noted by V ar(f ), which is defined by
V ar(f ) = E[(f − E(f ))2 ].
In other words, the variance measures the expected square of the deviation
of f from its expected value. The standard deviation of a random variable
f is the quantity is defined to be the square root of the variance.
Example 32.19
Show that if f and g are random variables then E(f + cg) = E(f ) + cE(g)
where c is a constant.
Solution.
Indeed,
P
E(f + cg) = P x∈S (f + cg)(x)P
P (x)
= x∈S f (x)P (x) + c x∈S g(x)P (x)
= E(f ) + cE(g)
Theorem 32.2

V ar(f ) = E(f 2 ) − (E(f ))2 .


Proof.
Indeed, using the previous exercise we have
V ar(f ) = E(f 2 − 2E(f )f + (E(f ))2 )
= E(f 2 ) − 2E(f )E(f ) + (E(f ))2
= E(f 2 ) − (E(f ))2
Example 32.20
Calculate V ar(f ) when f represents the outcome when a fair die is rolled.
Solution.
First note that
91
E(f 2 ) = (f (1))2 P (1) + · · · + (f (6))2 P (6) = .
6
By the above theorem we have
91 7 35
V ar(f ) = E(f 2 ) − (E(f ))2 = − ( )2 =
6 2 12
32 BASIC PROBABILITY TERMS AND RULES 189

Review Problems
Problem 32.1
What is the probability of drawing a red card from a well- shuffled deck of
52 playing cards?

Problem 32.2
If we roll a fair die, what are the probabilities of getting
a. a 1 or a 6;
b. an even number?

Problem 32.3
A department store’s records show that 782 of 920 women who entered the
store on a saturday afternoon made at least one purchase. Estimate the
probability that a woman who enters the store on a Saturday afternoon will
make at least one purchase.

Problem 32.4
Which of the following are mutually exclusive? Explain your answers.
a. A driver getting a ticket for speeding and a ticket for going through a red
light.
b. Being foreign-born and being President of the United States.

Problem 32.5
If A and B are the events that a consumer testing service will rate a given
stereo system very good or good, P (A) = 0.22, P (B) = 0.35. Find
a. P (Ac );
b. P (A ∪ B);
c. P (A ∩ B).

Problem 32.6
If the probabilities are 0.20, 0.15, and 0.03 that a student will get a failing
grade in Statistics, in English, or in both, what is the probability that the
student will get a failing grade in at least one of these subjects?

Problem 32.7
If the probability that a research project will be well planned is 0.60 and the
probability that it will be well planned and well executed is 0.54, what is the
probability that a well planned research project will be well executed?
190 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

Problem 32.8
Given three events A, B, and C such that P(A)=0.50, P(B)=0.30, and P (A∩
B) = 0.15. Show that the events A and B are independent.

Problem 32.9
There are 16 equally likely outcomes by flipping four coins. Let f repre-
sent the number of heads. Find the probability distribution and graph the
corresponding histogram.
33 BINOMIAL RANDOM VARIABLES 191

33 Binomial Random Variables


In this section we discuss an important example of a discrete random variable.
Binomial experiments are problems that consist of a fixed number of
trials n, with each trial having exactly two possible outcomes: Success and
failure. The probability of a success is denoted by p = P (S) and that of a
failure by q = P (F ). Moreover, p and q are related by the formula

p + q = 1.

Also, we assume that the trials are independent, that is what happens to
one trial does not affect the probability of a success in any other trial. The
central question of a binomial experiment is to find the probability of r suc-
cesses out of n trials. Now, anytime we make selections from a population
without replacement, we do not have independent trials. For example, se-
lecting a ball from a box that contain balls of two different colors. If the
selection is without replacement then the trials are dependent.

Example 33.1
The registrar of a college noted that for many years the withdrawal rate from
an introductory chemistry course has been 35% each term. We wish to find
the probability that 55 students out of 80 will register for the course.

a. What makes a trial?


b. What is a success? a failure?
c. What are the values of n, p, q, r?

Solution.
a. The decision of each student to withdraw or complete the course can be
thought as a trial. Thus, there are a total of 80 trials.
b. S = completing the course, F = withdrawing from course.
c. n = 80, p = .65, q = .35, r = 55.

Example 33.2
Harper’s Index states that 10% of all adult residents in Washington D.C.,
are lawyers. For a random sample of 15 adult Washington, D.C., residents,
we want to find the probability that 3 are lawyers.

a. What makes a trial?


192 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

b. What is a success? a failure?


c. What are the values of n, p, q, r?
Solution.
a. A trial is whether an adult resident of Washington, D.C. is a lawyer or
not.
b. S = being a lawyer, F = not being a lawyer.
c. n = 15, p = .1, q = .9, r = 3.

As mentioned earlier, the central problem of a binomial experiment is to


find the probability of r successes out of n independent trials. We next see
how to find these probabilities.
Recall from Section 6.1 the formula for finding the number of combinations
of n distinct objects taken r at a time
n!
C(n, r) = .
r!(n − r)!
We call the number C(n, r) the binomial coefficient. One commonly used
procedure for finding these coefficients is by means of Pascal’s triangle.

Now, the probability of r successes out of n independent trials is given by


the binomial distribution formula
P (r) = C(n, r)pr q n−r
where p = P (S) and q = P (F ) = 1 − p. The validity of the above equation
may be verified by first noting that the probability of any particular sequence
of the n outcomes with r successes and n − r failures is, by the independence
of trials, pr (1−p)n−r . Since C(n, r) counts the number of outcomes that have
r successes and n − r failures then the equation above follows.
Example 33.3
Find the probability that in tossing a fair coin three times there will appear
(a) 3 heads, (b)2 heads and 1 tail, (c) 2 tails and 1 head, and (d) 3 tails.
Solution.
a. C(3, 3)(.5)3 (.5)3−3 = 18 .
b. P (2) = C(3, 2)(.5)2 (.5) = 83 .
c. P (1) = C(3, 1)(.5)(.5)2 = 38 .
d. P (0) = C(3, 0)(.5)3 = 81
33 BINOMIAL RANDOM VARIABLES 193

Example 33.4
The probability that an entering college student will graduate is 0.4. Deter-
mine the probability that out of 5 students (a) none, (b) 1, (c) at least 1, (d)
all will graduate.

Solution.
(a) C(5, 0)(.6)5 .
(b) C(5, 1)(.4)(.6)4 .
(c) 1 − C(5, 0)(.6)5 .
(d) C(5, 5)(.4)5 .

Example 33.5
Find the probability of guessing correctly at least 6 of the 10 answers on a
true-false examination.

Solution.
P (6) + P (7) + P (8) + P (9) + P (10).

We next derive formulas for finding the expected value and standard de-
viation for the binomial random variable.

Theorem 33.1
a. The mean of a binomial random variable is given by µ = np.
b. The variance of a binomial random variable is given by σ 2 = npq.

Proof.
a. Using the definition of µ we have
Pn
µ = Pn i=0 iP (i)i n−i
= Pn i=1 iC(n, i)p q
n!
= np i=1 (i−1)!(n−i) pi−1 q n−i−1
Pn−1
= np i=0 C(n − 1, i)pi q n−1−i
= np(p + q)n−1 = np.
194 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY

b. Note first that i2 = i(i − 1) + i. Then


Pn 2
E(X 2 ) = Pn i=0 i P (i)
i n−i
= i=0 i(i − 1)C(n, i)p q +µ
P n n! i n−i
= i=2 (n−i)!(i−2)! p q + µ
n(n − 1)p2 ni=2 (n−i)!(i−2)!
(n−2)!
pi q n−i + µ
P
=
n−2
= n(n − 1)p2 j=0 C(n − 2, j)pj q n−2−j + µ
P

= n(n − 1)p2 (p + q)n−2 + µ


= n(n − 1)p2 + µ

It follows that
σ2 = E(X 2 ) − µ2
= n(n − 1)p2 + np − n2 p2
= npq
33 BINOMIAL RANDOM VARIABLES 195

Review Problems
Problem 33.1
At Community Hospital, the nursing staff is large enough so that 80% of the
time a nurse can respond to a room call within 3 minutes. Last night there
were 73 room calls. We wish to find the probability nurses responded to 62
of them within 3 minutes.

a. What makes a trial?


b. What is a success? a failure?
c. What are the values of n, p, q, r?

Problem 33.2
Find the probability that in a family of 4 children there will be (a) at least 1
boy and (b) at least 1 boy and 1 girl. Assume that the probability of a male
birth is 12 .

Problem 33.3
An insurance salesperson sells policies to 5 men, all of identical age and in
good health. According to the actuarial tables, the probability that a man
of this particular age will be alive 30 years is 32 . Find the probability that in
30 years (a) all 5 men, (b) at least 3 men, (c) only 2 men, (d) none will be
alive.
196 FUNDAMENTALS OF COUNTING AND PROBABILITY THEORY
Elements of Graph Theory

In this chapter we present the basic concepts related to graphs and trees such
as the degree of a vertex, connectedness, Euler and Hamiltonians circuits,
isomorphisms of graphs, rooted and spanning trees.

34 Graphs, Paths, and Circuits


An undirected graph G consists of a set VG of vertices and a set EG of
edges such that each edge e ∈ EG is associated with an unordered pair of
vertices, called its endpoints.
A directed graph or digraph G consists of a set VG of vertices and a set
EG of edges such that each edge e ∈ EG is associated with an ordered pair
of vertices.
We denote a graph by G = (VG , EG ).
Two vertices are said to be adjacent if there is an edge connecting the two
vertices. Two edges associated to the same vertices are called parallel. An
edge incident to a single vertex is called a loop. A vertex that is not incident
on any edge is called an isolated vertex. A graph with neither loops nor
parallel edges is called simple graph.

Example 34.1
Consider the following graph G

197
198 ELEMENTS OF GRAPH THEORY

a. Find EG and VG .
b. List the isolated vertices.
c. List the loops.
d. List the parallel edges.
e. List the vertices adjacent to v3 ..
f. Find all edges incident on v4 .
Solution.
a. EG = {e1 , e2 , e3 , e4 , e5 , e6 } and VG = {v1 , v2 , v3 , v4 , v5 , v6 , v7 }.
b. There is only one isolated vertex, v5 .
c. There is only one loop, e5 .
d. {e2 , e3 }.
e. {v2 , v4 }.
f. {e1 , e4 , e5 }.
Example 34.2
Which one of the following graphs is simple.

Solution.
a. G is not simple since it has a loop and parallel edges.
b. G is simple.

A complete graph on n vertices, denoted by Kn , is the simple graph that


contains exactly one edge between each pair of distinct vertices.
Example 34.3
Draw K2 , K3 , K4 , and K5 .
34 GRAPHS, PATHS, AND CIRCUITS 199

Solution.

A graph in which the vertices can be partitioned into two disjoint sets V1
and V2 with every edge incident on one vertex in V1 and one vertex of V2 is
called bipartite graph.

Example 34.4
a. Show that the graph G is bipartite.

b. Show that K3 is not bipartite.

Solution.
a. Clear from the definition and the graph.
b. Any two sets of vertices of K3 will have opposite parity. Thus, according
to the definition of bipartite graph, K3 is not bipartite.

A complete bipartite graph Km,n , is the graph that has its vertex set
partitioned into two disjoint subsets of m and n vertices, respectively. More-
200 ELEMENTS OF GRAPH THEORY

over, there is an edge between two vertices if and only if one vertex is in the
first set and the other vertex is in the second set.

Example 34.5
Draw K2,3 , K3,3 .

Solution.

The degree of a vertex v in an undirected graph, in symbol deg(v), is the


number of edges incident on it. By definition, a loop at a vertex contributes
twice to the degree of that vertex. The total degree of G is the sum of the
degrees of all the vertices of G.

Example 34.6
What are the degrees of the vertices in the following graph

Solution.
deg(v1 ) = 0, deg(v2 ) = 2, deg(v3 ) = 4.
34 GRAPHS, PATHS, AND CIRCUITS 201

Theorem 34.1
For any graph G = (VG , EG ) we have
X
2|EG | = deg(v).
v∈V (G)

Proof.
Suppose that VG = {v1 , v2 , · · · , vn } and |EG | = m. Let e ∈ EG . If e is a loop
then it contributes 2 to the total degree of G. If e is not a loop then let vi and
vj denote the endpoints of e. Then e contributes 1 to deg(vi ) and contributes
1 to the deg(vj ). Therefore, e contributes 2 to the total degree of G. Since
e was arbitrarily, this shows that each edge of G contributes 2 to the total
degree of G. Thus, X
2|EG | = deg(v)
v∈V (G)

The following is easily deduced from the previous theorem.

Theorem 34.2
In any graph there are an even number of vertices of odd degree.

Proof.
Let G = (VG , EG ) be a graph. By the previous theorem, the sum of all the
degrees of the vertices is T = 2|EG |, an even number. Let E be the sum of
the numbers deg(v), each which is even and O the sum of numbers deg(v)
each which is odd. Then T = E + O. That is, O = T − E. Since both T
and E are even then T is also even. This implies that there must be an even
number of the odd degrees. Hence, there must be an even number of vertices
with odd degree.

Example 34.7
Find a formula for the number of edges in Kn .

Solution.
Since G is complete, each vertex is adjacent to the remaining vertices. Thus,
the degree of each of the n vertices is n − 1, and we have the sum of the de-
grees of all of the vertices being n(n−1). By Theorem 34.1, n(n−1) = 2|EG |.
This completes a proof of the theorem
202 ELEMENTS OF GRAPH THEORY

In an undirected graph G a sequence P of the form v0 e1 v1 e2 · · · vn−1 en vn


is called a path of length n or a path connecting v0 to vn . If P is a path
such that v0 = vn then it is called a circuit or a cycle. A path or circuit is
simple if it does not contain the same edge more than once. A graph that
does not contain any circuit is called acyclic.

Example 34.8
In the graph below, determine whether the following sequences are paths,
simple paths, circuits, or simple circuits.

a. v0 e1 v1 e10 v5 e9 v2 e2 v1 .
b. v3 e5 v4 e8 v5 e10 v1 e3 v2 .
c. v1 e2 v2 e3 v1 .
d. v5 e9 v2 e4 v3 e5 v4 e6 v4 e8 v5 .

Solution.
a. a path (no repeated edge), not a simple path (repeated vertex v1 ), not a
circuit
b. a simple path
c. a simple circuit
d. a circuit, not a simple circuit (vertex v4 is repeated)

An undirected graph is called connected if there is a path between every


pair of distinct vertices of the graph. A graph that is not connected is said
to be disconnected.
34 GRAPHS, PATHS, AND CIRCUITS 203

Example 34.9
Determine which graph is connected and which one is disconnected.

Solution.
a. Connected.
b. Disconnected since there is no path connecting the vertices v1 and v4 .

A simple path that contains all edges of a graph G is called an Euler path.
If this path is also a circuit, it is called an Euler circuit.

Theorem 34.3
If a graph G has an Euler circuit then every vertex of the graph has even
degree.

Proof.
Let G be a graph with an Euler circuit. Start at some vertex on the circuit
and follow the circuit from vertex to vertex, erasing each edge as you go
along it. When you go through a vertex you erase one edge going in and one
edge going out, or else you erase a loop. Either way, the erasure reduces the
degree of the vertex by 2. Eventually every edge gets erased and all the ver-
tices have degree 0. So all vertices must have had even degree to begin with.

It follows from the above theorem that if a graph has a vertex with odd
degree then the graph can not have an Euler circuit.
The following provide a converse to the above theorem.
204 ELEMENTS OF GRAPH THEORY

Theorem 34.4 (Euler Theorem)


If all the vertices of a connected graph have even degree, then the graph has
an Euler circuit.

Example 34.10
Show that the following graph has no Euler circuit.

Solution.
Vertices v1 and v3 both have degree 3, which is odd. Hence, by the remark
following the previous theorem, this graph does not have an Euler circuit.

A path is called a Hamiltonian path if it visits every vertex of the graph


exactly once. A circuit that visits every vertex exactly once except for the
last vertex which duplicates the first one is called a Hamiltonian circuit.

Example 34.11
Find a Hamiltonian circuit in the graph

Solution.
vwxyzv
34 GRAPHS, PATHS, AND CIRCUITS 205

Example 34.12
Show that the following graph has a Hamiltonian path but no Hamiltonian
circuit.

Solution.
vwxyz is a Hamiltonian path. There is no Hamiltonian circuit since no cycle
goes through v.
206 ELEMENTS OF GRAPH THEORY

Review Problems

Problem 34.1
The union of two graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) is the graph
G1 ∪ G2 = (V1 ∪ V2 , E1 ∪ E2 ). The intersection of two graphs G1 = (V1 , E1 )
and G2 = (V2 , E2 ) is the graph G1 ∩ G2 = (V1 ∩ V2 , E1 ∩ E2 ).
Find the union and the intersection of the graphs

Problem 34.2
Graphs can be represented using matrices. The adjacency matrix of a graph
G with n vertices is an n×n matrix AG such that each entry aij is the number
of edges connecting vi and vj . Thus, aij = 0 if there is no edge from vi to vj .
a. Draw a graph with the adjacency matrix

 
0 1 1 0
 1 0 0 1 
 
 1 0 0 1 
0 1 1 0

b. Use an adjacency matrix to represent the graph


34 GRAPHS, PATHS, AND CIRCUITS 207

Problem 34.3
A graph H = (VH , EH ) is a subgraph of G = (VG , EG ) if and only if VH ⊆ VG
and EH ⊆ EG .
Find all nonempty subgraphs of the graph

When (u, v) is an edge in a directed graph G then u is called the ini-


tial vertex and v is called the terminal vertex. In a directed graph,
the in-degree of a vertex v, denoted by deg − (v), is the number of edges
with v as their terminal vertex. Similarly, the out-degree of v, denoted
by deg + (v), is the number of edges with v as an initial vertex. Note that
deg(v) = deg + (v) + deg − (v).
208 ELEMENTS OF GRAPH THEORY

Problem 34.4
Find the in-degree and out-degree of each of the vertex in the graph G with
directed edges.

Problem 34.5
Show that for a digraph G = (VG , EG ) we have

X X
|EG | = deg − (v) = deg + (v).
v∈V (G) v∈V (G)

Another useful matrix representation of a graph is known as the incidence


matrix. It is constructed as follows. We label the rows with the vertices
and the columns with the edges. The entry for row v and column e is 1 if e
is incident on v and 0 otherwise. If e is a loop at v we assign the value 2. It
is easy to see that the sum of entries of each column is 2 and that the sum
of entries of a row gives the degree of the vertex corresponding to that row.

Problem 34.6
Find the incidence matrix corresponding to the graph
34 GRAPHS, PATHS, AND CIRCUITS 209

Problem 34.7
If each vertex of an undirected graph has degree k then the graph is called a
regular graph of degree k.
How many edges are there in a graph with 10 vertices each of degree 6?

Problem 34.8
Two simple graphs G1 and G2 are isomorphic, in symbol, G1 ' G2 , if there
is one-to-one onto function, f : V (G1 ) → V (G2 ) and AG1 = AG2 . Show that
the following graphs are isomorphic.

Warning: The number of vertices, the number of edges, and the degrees of
the vertices are all invariants under isomorphism. If any of these quantities
210 ELEMENTS OF GRAPH THEORY

differ in two graphs, these graphs cannot be isomorphic. However, when these
invariants are the same, it does not necessarily mean that the two graphs are
isomorphic.
The isomorphism between two graphs G1 = (VG1 , EG1 ) and G2 = (VG2 , EG2 )
with parallel edges or loops requires two bijections f : VG1 → VG2 and g :
EG1 → EG2 such that if e ∈ EG1 is an edge with endpoints (u, v) then
g(e) ∈ EG2 is an edge with endpoints (f (u), f (v)).

Problem 34.9
Show that the following graphs are not isomorphic.

Problem 34.10
Show that the following graph has no Hamiltonian path.
35 TREES 211

35 Trees
An undirected graph is called a tree if each pair of distinct vertices has ex-
actly one path. Thus, a tree has no parallel edges and no loops.
We next show a result that is needed for the proof of our first main theorem
of trees.

Theorem 35.1
Any tree with more than one vertex has at least one vertex of degree 1.

Proof.
Let v0 and vn be two distinct vertices. Then there is a path connecting v0 to
vn . By the definition of a tree, there is only one edge incident on either v0 or
vn . Thus deg(v0 ) = deg(v1 ) = 1. .

The following is the first of the two main theorems about trees:

Theorem 35.2
A tree with n vertices has exactly n − 1 edges.

Proof.
The proof is by induction on n ≥ 1. Let P (n) be the property: Any tree with
n vertices has n − 1 edges.
Basis of induction: P (1) is valid since a tree with one vertex has zero edges.
Induction hypothesis: Suppose that P (n) holds up to n ≥ 1.
Induction Step: We must show that any tree with n + 1 vertices has n edges.
Indeed, let T be any tree with n + 1 vertices. Since n + 1 ≥ 2 then by the
previous theorem, T has a vertex v of degree 1. Let T0 be the graph obtained
by removing v and the edge attached to v. Then T0 is a tree with n vertices.
By the induction hypothesis, T0 has n − 1 edges and so T has n edges

Example 35.1
Which of the following graphs are trees?
212 ELEMENTS OF GRAPH THEORY

Solution.
The first graph satisfies the definition of a tree. The second and third graphs
do not satisfy the conclusion of Theorem 35.2 and therefore they are not
trees.

The second major theorem about trees is the following theorem whose proof
is omitted.

Theorem 35.3
Any connected graph with n vertices and n − 1 edges is a tree.

A rooted tree is a tree in which a particular vertex is designated as the


root. The level of a vetex v is the length of the simple path from the root
to v. The height of a rooted tree is the maximum level number that occurs.

Example 35.2
Find the level of each vertex and the height of the following rooted tree.
35 TREES 213

Solution.
v1 is the root of the given tree.
vertex level
v2 1
v3 1
v4 2
v5 2
v6 2
v7 2
The height of the tree is 2.

Let T be a rooted tree with root v0 . Suppose (v0 , v1 , · · · , vn ) is a simple


path in T and x, y, z are three vertices. Then
(a) vn−1 is the parent of vn .
(b) v0 , v1 , · · · , vn−1 are the ancestors of vn .
(c) vn is the child of vn−1 .
(d) If x is an ancestor of y then y is a descendant of x.
(e) If x and y are children of z then x and y are siblings.
(f) If x has no children, then x is a leaf.
(g) The subtree of T rooted at x is the graph with vertex V and edge set
E, where V is x together with the descendants of x and
E = {e|e is an edge on a simple path f rom x to some vertex in V }.
Example 35.3
Consider the rooted tree
214 ELEMENTS OF GRAPH THEORY

a. Find the parent of v6 .


b. Find the ancestors of v13 .
c. Find the children of v3 .
d. Find the descendants of v11 .
e. Find an example of a siblings.
f. Find the leaves.
g. Construct the subtree rooted at v7 .

Solution.
a. v2 .
b. v1 , v3 , v7 .
c. v7 , v8 , v9 .
d. None.
e. {v2 , v3 , v4 , v5 }.
f. {v4 , v5 , v6 , v9 , v9 , v10 , v11 , v12 , v13 }.
g.

A binary tree is a rooted tree such that each vertex has at most two chil-
dren. Moreover, each child is designated as either a left child or a right
child.

Example 35.4
a. Show that the following tree is a binary tree.
35 TREES 215

b. Find the left child and the right child of vertex v5 .


c. A full binary tree is a binary tree in which each vertex has either two
children or zero children. Construct an example of a full binary tree.

Solution.
a. Follows from the definition of a binary tree.
b. The left child is v6 and the right child is v7 .
c.

Example 35.5
A forest is a simple graph with no circuits. Which of the following graphs
is a forest?
216 ELEMENTS OF GRAPH THEORY

Solution.
The first graph is a forest whereas the second is not.

Example 35.6
a. Let T be a subgraph of a graph G such that T is a tree containing all of
the vertices of G. Such a tree is called a spanning tree. Find a spanning
tree of the following graph.

b. The following algorithm finds a spanning tree. In this algorithm S denotes


a sequence. Let G be a connected graph with vertices ordered

v 1 , v 2 , , · · · , vn

1. Let T be the tree with root v1 and no edges.


2. Add to T all edges (v1 , x) and vertices on which they are incident, provided
35 TREES 217

that (v1 , x) deos not produce a circuit. If no edges can be added, stop (T is
a spanning tree)
3. Replace S by the children in T of S ordered consistently with the original
ordering. Go to step 2.
Use the above algorithm to find the spanning tree of part a.

Solution.
a.
218 ELEMENTS OF GRAPH THEORY

Review Problems
Problem 35.1
Find the level of each vertex and the height of the following rooted tree.

Problem 35.2
Consider the rooted tree

a. Find the parent of v6 .


b. Find the ancestors of v10 .
35 TREES 219

c. Find the children of v4 .


d. Find the descendants of v1 .
e. Find all the siblings.
f. Find the leaves.
g. Construct the subtree rooted at v1 .
Problem 35.3
The binary tree below gives an algorithm for choosing a restaurant. Each
internal vertex asks a question. If we begin at the root, answer each ques-
tion, and follow the appropriate edge, we will eventually arrive at a terminal
vertex that chooses a restaurant. Such a tree is called a decision tree.

Construct a decision tree that sorts three given numbers a1 , a2 , a3 in as-


cending order.
Problem 35.4
A binary search tree is a binary tree T in which data are associated with
the vertices. The data are arranged so that, for each vertex v in T, each data
item in the left subtree of v is less than the data item in v and each data item
in the right subtree of v is greater than the data item in v. Using numerical
order, form a binary search tree for a number in the set {1, 2, · · · , 15}.
Problem 35.5
Procedures for systematically visiting every vertex of a tree are called tra-
versal algorithms. In the preorder traversal, the root r is listed first
220 ELEMENTS OF GRAPH THEORY

and then the subtrees T1 , T2 , · · · , Tn are listed, from left to right, in order
of their roots. The preorder traversal begins by visiting r. It continues by
traversing T1 in preorder, thenT2 in preorder, and so on, until Tn is traversed
in preorder. In which order does a preorder traversal visit the vertices in the
following rooted tree?

You might also like