You are on page 1of 3

Problem 1.

Determine whether each of these proposed definitions is a valid 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)=2f(n-2), for n 1, n is even
f(n) = 2f(n-2)= 22f((n-2)-2)= 23f(n-32) =24f(n-42) =..2kf(n-k2)=
= 2(n-2)/2f(2)= 22(n-2)/2
n-k2 = 2; n = 2 + 2k; n-2 = 2k, k =(n-2)/2
b) f(0)=1, f(n) = f(n-1) 1, for n 1
f(n)= f(n-1) 1= f(n-2)-2= f(n-k) k = = f(n-n) n = 1 - n
n-k = 0, k=n
c) f(0)=2, f(1)=3, f(n)=f(n-1) 1, for n 2
f(n) = f(n-1) 1= f(n-2)-2= f(n-k) k = = f(n-(n-1)) (n-1)= f(1) n+1=4-n
n-k=1 , k = n-1
d) f(0)=1, f(1)=2, f(n)= 2f(n-2), for n 2
f(n) = 2f(n-2) = . =24f(n-42) = 2kf(n-k2) = 2n/2
n-k2 = 0 ..
e) f(0)=1, f(n)= 3f(n-1) if n is odd and n 1 and f(n)= 9f(n-2) if n is even and n 2

Problem 2.
Give a recursive definition of the sequence {a n}, n=1,2,3 if
a) an = 6n
a0=0 ; an+1 = 6(n+1)=6n + 6 = an + 6
b) an = 2n +1
a0 = 1; an+1 = 2(n+1) + 1 = (2n +1) + 2 = an + 2
c) an = 10n
a0 = 1 ; an+1 = 10n+1 = 10n10 = 10an
d) an = 5

Problem 3.
Assuming that fn is the nth Fibonacci number [f0=f1=1; fn+1= fn+ fn-1],
prove that f02 + f12 + + fn2 = fnfn+1
when n is a positive integer.

Basic step: f02 = 12 = f0f1 =11=1


Inductive step: assumption - f02 + f12 + + fn2 = fnfn+1
We have to prove: f02 + f12 + + fn2 + fn+12 = fn+1fn+2
fnfn+1+ fn+12 = fn+1fn+2 = fn+1(fn+1+ fn)
Problem 4.
Give a recursive definition of
a) the set S of odd positive integers
1 S, k S k+2 S
b) the set S of positive integer powers of 3
S = {31, 32, }
3 S , k S 3k S
c) the set S of polynomials with integer coefficients
S = {a0 + a1x + a2x2 +. akxk : (i k)[ai N]}
a N, k N {0} axk S
s1 , s2 S s1 + s2 S

Problem 5.
Give a recursive definition of each of these sets of ordered pairs of positive integers.
Use structural induction to prove that the recursive definition you found is correct.
[Hint: To find a recursive definition, plot the points in the set in the plane and look for
paterns]
a) S={(a,b): aZ+, bZ+, and a+b is even}
(1,1) S, (2,2) S,
(p,q) S (p, q+2) S, (p+2,q) S
b) S={(a,b): aZ+, bZ+, and a or b is odd}
(1,1) S, (1,2) S, (2,1) S
(p,q) S (p, q+2) S, (p+2,q) S
c) S={(a,b): aZ+, bZ+, a+b is odd, 3 b}
(2,3) S , (1,6) S
(p,q) S (p,q+6) S, (p+2,q) S

Problem 6.
Give a recursive algorithm for finding the sum of the first n positive integers

Procedure S(n: integer)


if n=1 then S(n):=1
else S(n):= S(n-1) + n

Problem 7.
Give a recursive algorithm for finding the minimum of a finite set of integers, making use
of the fact that the minimum 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.

Procedure S(a1,a2,,an: integers)


if n=1 then S(a1,a2,,an):=a1
else S(a1,a2,,an):= min(S(a1,a2,,an-1), an)
Problem 8.
Device a recursive algorithm for computing n 2 where n is a nonnegative integer using
the fact that (n+1)2 = n2 + 2n + 1.

Procedure S(n: nonnegative)


if n=0 then S(n):= 0
else S(n):= S(n-1) + 2(n-1) + 1

Problem 9.
Device a recursive algorithm to find the nth term of the sequence defined by a0=1, a1=2,
an = an-1an-2, for n=2,3,4,.

Procedure S(n: nonnegative)


if n=0 then S(n):= 1
else if n=1 then S(n):= 2
else S(n):= S(n-1) S(n-2)

You might also like