You are on page 1of 3

MAD111 - Review Chapter 4

1. Find the correct order of steps of a proof by induction of the proposition:


1 + 2 + … + n = n(n+1)/2

(1) Assume that the statement is true for


n = k.
(2) n = 1, we have 1 = 1.2/2, so the
statement is true for n = 1.
(3) by the inductive hypothesis, we get
1 + 2 + … + (k+1) =
k(k+1)/2 + (k+1) = (k+1)(k+2)/2
(4) We will prove that the statement is
true for n = k+1.
(5) The statement is proved.
(6) Indeed: 1 + 2 + … + (k+1) =
(1 + 2 + … + k) + k +1.
(7) We have 1 + 2 + … + k = k(k+1)/2

A. 1243765 B. 2174635
C. 2146735 D. None

2. Given the sequence

a1 = 1, a2 = 2, an = 2an-1 + an-2. Find a6.

A.64 B. 70 C. 29 D. None

3. The sequence am,n is defined recursively by:


a0,0 = 1 and
�am-1,n + 2m, khi n = 0, m > 0

am , n = �
�am,n -1 - n, khi n > 0
Find a2,3.

A. 0 B. 1 C. -3 D. None

4. Let Sn be the sum of the first n odd positive integers. Find a recursive definition for Sn.

A. Sn = n2, n = 1, 2, …
B. S1 = 1, Sn = Sn-1 + 1 where n > 1.
C. S1 = 1, Sn = Sn-1 + n where n > 1.
D. S1 = 1, Sn = Sn-1 + 2n-1 where n > 1.

5. Which is NOT a recursive definition for the set of integer divisible by 3?


A. 0  S; If x  S then x + 3, x - 3  S.
B. 3  S; If x  S then x + 3, x - 3  S.
C. 0  S; If x, y  S then x - y  S.
D. 3  S; If x, y  S then x - y  S.

6. Given the algorithm

procedure sq(n :negative integer)


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

Compute sq(5).

A. 11 B 25 C. 37 D. None

7. How many comparisons are required to merge the two lists


[4, 5, 8, 12, 20, 23] and [1, 3, 9, 10]?

A. 6 B. 7 C. 9 D. None

8. Given the program segment

if x < 0 then y: = 6|x|/x


else
if x > 0 then y:= 7|x|/x
else y:=8

With the initial assertion x = -3, find the final assertion.

A. y = 6 B. y = -7
C. y = - 6 D. y = 8 E. None

9. Given the program segment


s: = 1
i: = 1
while i < n do
begin
i: = i + 1,
s: = s + i2
end
Find a loop invariant for this program segment.

A. (s = 12 + 22 +… + i2)  (i < n)
B. (s = 12 + 22 +… + i2)  (i ≤ n)
C. (s = 12 + 22 +… + (i-1)2)  (i < n)
D. (s = 12 + 22 +… + (i-1)2)  (i ≤ n)
Key: 1B, 2B, 3B, 4D, 5C, 6D, 7B, 8C, 9B

You might also like