when n is a positive integer. 19. By taking
determinants of both sides of the
equation in Exercise 18, prove the identity
given in Exercise 14. (Recall that the
determinant of the matrix a b c d is ad
bc.) 20. Give a recursive definition of
the functions

recursively by f (0) = 1 and for n = 0, 1, 2,.
a) f (n + 1) = f (n) + 2. b) f (n + 1) = 3f (n).
c) f (n + 1) = 2f (n). d) f (n + 1) = f (n)2 + f
(n) + 1. 2. Find f (1), f (2), f (3), f (4), and f
(5) if f (n) is defined recursively by f (0) =
3 and for n

or numeral). Well-formed formulae
generated by applying the recursive step
once include (x + 3), (3 + y), (x y), (3
0), (x 3), (3 y), (3/0), (x/y), (3x), and
(03). Applying the recursive step twice
shows that formulae such as (x + 3) + 3)
and (x (3 y) ar

in algorithms for compressing data, and in
many other applications. We first define
extended binary trees. DEFINITION 4 The
set of extended binary trees can be
defined recursively by these steps: BASIS
STEP: The empty set is an extended
binary tree. RECUR

holds for these new elements. The validity
of structural induction follows from the
principle of mathematical induction for
the nonnegative integers. To see this, let P
(n) state that the claim is true for all
elements of the set that are generated by
n o

by the recursive definition of h(T ) =
2h(T )+1 1. This completes the recursive
step. Generalized Induction We can
extend mathematical induction to prove
results about other sets that have the
wellordering property besides the set of
integers. Although we

length n + 1 as xy, where x is a string of
length n, and express the reversal of w in
terms of xR and y.] 36. Use structural
induction to prove that (w1w2)R = wR 2
wR 1 . 37. Give a recursive definition of
wi , where w is a string and i is a
nonnegative i

3, which is a recursive version of the
Euclidean algorithm. We illustrate the
workings of Algorithm 3 with a trace
when the input is a = 5, b = 8. With this
input, the algorithm uses the else clause
to find that gcd(5, 8) = gcd(8 mod 5, 5) =
gcd(3, 5). It

deal with iterations of the logarithm
function. Let log n denote the logarithm of
n to the base 2, as usual. The function
log(k) n is defined recursively by log(k) n
= n if k = 0 log(log(k1)
n) if log(k1) n is defined and positive
undefined otherwise. The

element in the first list into the second
list. This requires only log n comparisons,
which is much smaller than m + n 1 = n,
for m = 1. On the other hand, for some
values of m and n, Lemma 1 gives the best
possible bound. That is, there are lists
with m

recursive definition of a function f from
the set of nonnegative integers to the set
of integers. If f is well defined, find a
formula for f (n) when n is a nonnegative
integer and prove that your formula is
valid. a) f (0) = 1, f (n) = f (n 1) for n 1
b)

members of a set constructed recursively
have a particular property. We will
illustrate this idea by using structural
induction to prove results about wellformed formulae, strings, and binary
trees. For each proof, we have to carry out
the appropriate bas

step of the definition specifies that 3 is in
S. Because 3 = 3 1, all elements specified
to be in S in this step are divisible by 3
and are therefore in A. To finish the proof,
we must show that all integers in S
generated using the second part of the
rec

recursively by Basis step: (0, 0) S.
Recursive step: If (a, b) S, then (a + 2, b
+ 3) S and (a + 3, b + 2) S. a) List the
elements of S produced by the first five
applications of the recursive definition. b)
Use strong induction on the number of
applicati

of 5 and of 6 using this recursive
definition. Consider an inductive
definition of a version ofAckermanns
function. This function was named after
WilhelmAckermann, a German
mathematician who was a student of the
great mathematician David Hilbert.
Ackerman

number of vertices in a full binary tree,
we observe that n(T ) satisfies the
following recursive formula: BASIS STEP:
The number of vertices n(T ) of the full
binary tree T consisting of only a root r is
n(T ) = 1. RECURSIVE STEP: If T1 and T2
are full b

definition you found is correct. [Hint: To
find a recursive definition, plot the points
in the set in the plane and look for
patterns.] a) S = cfw_(a, b)| a Z+, b Z+,
and a + b is even b) S = cfw_(a, b)| a Z+, b
Z+, and a or b is odd c) S = cfw_(a, b)| a

the root to each of the roots of the left
subtree T1 and the right subtree T2.
Figure 4 shows how full binary trees are
built up by applying the recursive step
one and two times. Structural Induction
To prove results about recursively defined
sets, we gen

contain an equal number of left and right
parentheses. RECURSIVE STEP: Assume p
and q are well-formed formulae each
containing an equal number of left and
right parentheses. That is, if lp and lq are
the number of left parentheses in p and q,
respectively

hypothesis, l(xy) = l(x) + l(y). We conclude
that l(xya) = l(x) + l(y) + 1 = l(x) + l(ya).
We can prove results about trees or
special classes of trees using structural
induction. For example, to prove a result
about full binary trees using structural
in

formed formulae. For example, by the
basis step we know that T, F, p, and q are
well-formed formulae, where p and q are
propositional variables. From an initial
application of the recursive step, we know
that (p q), (p F), (F q), and (q F)
are well-formed

Mathematical induction, and its variant
strong induction, can be used to prove
that a recursive algorithm is correct, that
is, that it produces the desired output for
all possible input values. Examples 7 and
8 illustrate how mathematical induction
or str

graph formed by starting with a root r,
which is not in any of the rooted trees T1,
T2,.,Tn, and adding an edge from r to
each of the vertices r1, r2,.,rn, is also a
rooted tree. In Figure 2 we illustrate some
of the rooted trees formed starting with
the

remove it from the second list. At this
stage the first list is 5, 6, the second list is
empty, and the combined list is 1, 2, 3, 4.
Finally, because the second list is empty,
all elements of the first list can be
appended to the end of the combined list

T2 is the union of the sets of leaves of T1
and of T2. The internal vertices of T are
the root r of T and the union of the set of
internal vertices of T1 and the set of
internal vertices of T2. 44. Use structural
induction to show that l(T ), the number
o

of n integers is the smaller of the last
integer in the list and the minimum of the
first n 1 integers in the list. 12. Devise a
recursive algorithm for finding xn mod m
whenever n, x, and m are positive integers
based on the fact that xn mod m = (xn1
mod

that the program segment if x y min
= y). 5. Devise a rule of inference for
verification of partial correctness of
statements of the form if condition 1
then S1 else if condition 2 then S2 . . .
else Sn where S1, S2,.,Sn are blocks. 6.
Use the rule of inf

estimate for Algorithm 10. Each time a
comparison of an element from L1 and an
element from L2 is made, an additional
element is added to the merged list L.
However, when either L1 or L2 is empty,
no more comparisons are needed. Hence,
Algorithm 10 is lea

version of a binary search algorithm.
Solution: Suppose we want to locate x in
the sequence a1, a2,.,an of integers in
increasing order. To perform a binary
search, we begin by comparing x with the
middle term, a(n+1)/2. Our algorithm will
terminate if x