Lecture Notes in Discrete Mathematics - Part 7
Lecture Notes in Discrete Mathematics - Part 7
Marcel B. Finan
Arkansas Tech University
All
c Rights Reserved
22 RECURSION 141
Review Problems
Problem 22.1
Find the first four terms of the following recursively defined sequence:
v1 = 1, v2 = 2
vn = vn−1 + vn−2 + 1, n ≥ 3
Problem 22.2
Prove each of the following for the Fibonacci sequence:
a. Fk2 − Fk−1
2
= Fk Fk+1 − Fk+1 Fk−1 , k ≥ 1.
2
b. Fk+1 − Fk2 − Fk−1
2
= 2Fk Fk−1 , k ≥ 1.
2 2
c. Fk+1 − Fk = Fk−1 Fk+2 , k ≤ 1.
2
d. Fn+2 Fn − Fn+1 = (−1)n for all n ≥ 0.
Problem 22.3
Find limn→∞ FFn+1
n
where F0 , F1 , F2 , · · · is the Fibonacci sequence. (Assume
that the limit exists.)
Problem 22.4
Define x0 , x1 , x2 , · · · as follows:
p
xn = 2 + xn−1 , x0 = 0.
Find limn→∞ xn .
Problem 22.5
a. Make a list of all bit strings of lengths zero, one, two, three, and four that
do not contain the pattern 111.
b. For each n ≥ 0 let dn = the number of bit strings of length n that do not
contain the bit pattern 111. Find d0 , d1 , d2 , d3 , and d4 .
c. Find a recurrence relation for d0 , d1 , d2 , · · ·
d. Use the results of (b) of (c) to find the number of bit strings of length five
that do not contain the pattern 111.
Problem 22.6
Find a formula for each of the following sums:
a. 1 + 2 + · · · + (n − 1), n ≥ 2.
b. 3 + 2 + 4 + 6 + 8 + · · · + 2n, n ≥ 1.
c. 3 · 1 + 3 · 2 + 3 · 3 + · · · 3 · n, n ≥ 1.
142 RELATIONS AND FUNCTIONS
Problem 22.7
Find a formula for each of the following sums:
a. 1 + 2 + 22 + · · · + 2n−1 , n ≥ 1.
b. 3n−1 + 3n−2 + · · · + 32 + 3 + 1, n ≥ 1.
c. 2n + 3 · 2n−2 + 3 · 2n−3 + · · · + 3 · 22 + 3 · 2 + 3, n ≥ 1.
d. 2n − 2n−1 + 2n−2 − 2n−3 + · · · + (−1)n−1 · 2 + (−1)n , n ≥ 1.
Problem 22.8
Use iteration to guess a formula for the following recusively defined sequence
and then use mathematical induction to prove the validity of your formula:
c1 = 1, cn = 3cn−1 + 1, for all n ≥ 2.
Problem 22.9
Use iteration to guess a formula for the following recusively defined sequence
and then use mathematical induction to prove the validity of your formula:
w0 = 1, wn = 2n − wn−1 , for all n ≥ 2.
Problem 22.10
Determine whether the recursively defined sequence: a1 = 0 and an = 2an−1 +
n − 1 satisfies the explicit formula an = (n − 1)2 , n ≥ 1.
Problem 22.11
Which of the following are second-order homogeneous recurrence relations
with constant coefficients?
a. an = 2an−1 − 5an−2 .
b. bn = nbn−1 + bn−2 .
c. cn = 3cn−1 · c2n−2 .
d. dn = 3dn−1 + dn−2 .
e. rn = rn−1 − rn−2 − 2.
f. sn = 10sn−2 .
Problem 22.12
Let a0 , a1 , a2 , · · · be the sequence defined by the explicit formula
an = C · 2n + D, n ≥ 0
where C and D are real numbers.
a. Find C and D so that a0 = 1 and a1 = 3. What is a2 in this case?
b. Find C and D so that a0 = 0 and a1 = 2. What is a2 in this case?
22 RECURSION 143
Problem 22.13
an = C · 2n + D, n ≥ 0
where C and D are real numbers. Show that for any choice of C and D,
an = 3an−1 − 2an−2 , n ≥ 2.
Problem 22.14
Let a0 , a1 , a2 , · · · be the sequence defined by the explicit formula
a0 = 1, a1 = 2
an = 2an−1 + 3an−2 , n ≥ 2
Problem 22.15
Let a0 , a1 , a2 , · · · be the sequence defined by the explicit formula
a0 = 1, a1 = 4
an = 2an−1 − an−2 , n ≥ 2
Problem 22.16
The triangle inequality for absolute value states that for all real numbers a
and b, |a+b| ≤ |a|+|b|. Use the recursive definition of summation, the triangle
inequality, the definition of absolute value, and mathematical induction to
prove that for all positive integers n, if a1 , a2 , · · · , an are real numbers then
n
X n
X
| ak | ≤ |ak |.
k=1 k=1
Problem 22.17
Use the recursive definition of union and intersection to prove the following
general distributive law: For all positive integers n, if A and B1 , B2 , · · · , Bn
are sets then
A ∩ (∪nk=1 Bk ) = ∪nk=1 (A ∩ Bk ).
144 RELATIONS AND FUNCTIONS
Problem 22.18
Use mathematical induction to prove the following generalized De Morgan’s
law.
(∩ni=1 Ai )c = ∪ni=1 Aci
Exercise 367
Show that the relation F : IN → Z given by the rule
1 if n = 1.
n
F (n) = F(2) if n is even
1 − F (5n − 9) if n is odd and n > 1
The ”bi” in binary relation R refers to the fact that R is a subset of the
cartesian product of two sets. Let A1 , A2 , · · · , An be given sets. If R is a
subset of A1 × A2 × · · · × An then we call R an n-ary relation. An n-ary
relation can be represented by a table or a set of ordered n-tuples.
Example 23.1
Problem 23.1
a. Express the above 4-ary as a set of 4-tuples.
b. Answer the query: PLAYER[Name]
c. Answer the query: PLAYER[Name, Position]
Part II: Representing a Relation by a Matrix.
If the numbers on the main diagonal of M (R) are all equal to 1 then R is
reflexive. If M (R)T = M (R), where M (R)T is the transpose of M (R), then
the relation R is symmetric. If mij = 0 or mji = 0 for i 6= j then R is
antisymmetric.
Problem 23.2
Let A = {1, 2, 3} and R = {(1, 1), (1, 2), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}.
Find M (R) and use it to determine if the relation R is reflexive, symmetric
or antisymmetric.
Part III: Cryptology
An important application to congruences is cryptology, which is the study of
secret messages.
Problem 23.4
What is the message produced from the encrypted message ”PHHW BRX
LQ WKH SDUN”?
148 RELATIONS AND FUNCTIONS
Problem 25.1
Ten persons have first names George, William, and Laura and last names
Bush, Perry, and Gramm. Show that at least two persons have the same
first and last names.
Problem 25.2
Let S be a finite set and {A1 , A2 , · · · , An } be a partition of S. Use the method
of contradiction to show that there is an index 1 ≤ i ≤ n such that |Ai | ≥ |S| n
.
One can uses the previous exercise to solve the following exercise.
Problem 25.3
Let S and T be two finite sets such that |S| > k|T | where k is a positive
integer. Show that for any function f : S → T there is a t ∈ T such that the
set {s ∈ S : f (s) = t} has more than k elements.
Hint: Show that the family At = {s ∈ S : f (s) = t}, where t ∈ T, partitions
S into n sets with n ≤ |T |. Then apply the previous exercise.
Problem 25.4
If S and T are finite sets such that |S| > |T | then any function f : S → T is
not one-to-one.
150 RELATIONS AND FUNCTIONS
We say that two sets have the same cardinality if and only if there is a
bijective function between them. A set A is called countably infinite if
and only if A has the same cardinality as the set IN∗ of positive integers. A
set A is called countable if it is either finite or countably infinite. A set
that is not countable is said to be uncountable. Examples of uncountable
sets are IR and the intervals in IR..
The purpose of this project is to look at some countably infinite sets.
Problem 26.1
Show that the function f : IN∗ → IN given by f (n) = n − 1 is a bijective
function. Thus, IN is countably infinite.
Problem 26.2
Show that the function f : IN∗ → Z defined by
n
2
if n is even
f (n) = 1−n
2
if n is odd
Problem 26.3
Show that the function f : Z → 2Z Z defined by f (n) = 2n is a bijective
function. Hence, the set of even integers is countably infinite.
Problem 26.4
Show that the set of rational numbers Q
I is countably infinite. (Hint:
26 PROJECT X: COUNTABLE SETS 151
)
152 RELATIONS AND FUNCTIONS
Problem 27.1
Consider the finite-state automaton defined by the transition diagram
27 PROJECT XI: FINITE-STATE AUTOMATON 153
Problem 27.2
Consider the finite-state automaton defined by the following transition dia-
gram
154 RELATIONS AND FUNCTIONS
a. To what states does A go if the symbols of the following words are input
to A in sequence starting from the initial state?
(i) 1101 (ii) 0011 (iii) 0101010.
b. Which of the words in part (a) send A to an accepting state?
c. Show that L(A) = {0(10)n : n ≥ 0} where (10)n = 1010 · · · with n copies
of 10 juxtaposed into one word.
Problem 27.3
A finite-state automaton A, given by the transition diagram below, has tran-
sition function N and eventual-state functioin N ∗ .
27 PROJECT XI: FINITE-STATE AUTOMATON 155
Problem 27.4
Design a finite-state machine that recognizes words of the form 01, 011, 0111, 01111, · · · .
156 RELATIONS AND FUNCTIONS
Introduction to the Analysis of
Algorithms
157
158 INTRODUCTION TO THE ANALYSIS OF ALGORITHMS
an algorithm; that is, the longest running time for any input of size n.
Since we are considering asymptotic efficiency of algorithms, basically we will
be focusing on the leading term of T (n). For example, if T (n) = 4n3 − 2n2 +
n + 5 then T (n) = n3 (4 − n2 + n1 + n5 ) and for large n we have T (n) ∼ n3 . We
say that T (n) has a growth of order n3 .
We say that one algorithm is more efficient then another if its worse case
running time has a lower order of growth.
Example 28.1
Estimate the time complexity of the following algorithm:
i := 1
p := 1
for i := 1 to n
p := p · i
i := i + 1
next i
Solution.
Prior to entering the loop, it takes two assignment statements to initialize
the variables i and p. The loop is executed n times, and each time it executes
the two assignment statements in the body of the loop with a total of two
arithmetic operations. Thus, the time complexity of the algorithm is given
by
T (n) = 4n + 2
so the growth is of order n.
Example 28.2
What is the run-time complexity based on n for the following program sege-
ment:
for i := 1 To n
for j := 1 To n
A(i,j) := x
next j
next i
Solution.
The inner loop is executed n times and the outer loop also is executed n
28 TIME COMPLEXITY AND O-NOTATION 159
In the above two problems we found a precise expression for the time com-
plexity of the algorithm. What usually interests us is the order of growth.
We next introduce some of the concepts of growth orders. Let g : IN → IR.
We define the set
s := 0
for i := 1 To n
for j := 1 To i
s := s + j · (i − j + 1)
next j
next i
Solution.
Prior to entering the loop there is one assignment statement. Now, there are
two additions, one subtraction, one multiplication and one assignment for
each iteration of the inner loop. The total number of time the inner loop is
executed is
n(n + 1)
1 + 2 + 3 + ··· + n =
2
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?