Lecture Notes in Discrete Mathematics - Part 6
Lecture Notes in Discrete Mathematics - Part 6
Marcel B. Finan
Arkansas Tech University
All
c Rights Reserved
166 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
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
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
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
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
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.
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
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
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
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
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.
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)
Proof.
The proof is by induction.
Indeed, we have
Example 31.9
Expand (x + y)6 using the binomial theorem.
Solution.
By the Binomial Theorem and Pascal’s triangle we have
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
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
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.
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 .
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
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
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?
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,
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
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.
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
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
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.
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.
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
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.
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.
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.
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.
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.
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)
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
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)
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
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.
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
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
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)
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.
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.
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
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.
v 1 , v 2 , , · · · , vn
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
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?