Solutions Week 6
Solutions Week 6
1
Lecturers: Dr Nguyen Hieu Thao & Dr Jeff Nijsse
Email: [email protected]
Proof.
1 Some of the content of this document is taken from the book [1].
2
min(x1 , x2 , · · · , xn ) :
if n = 1 : return x1
else if n = 2 : if x1 ≤ x2 return x1 , else return x2
else : return min (min(x1 , x2 , . . . , xn−1 ), xn ) .
reverse(x1 , x2 , · · · , xn ) :
if n = 1 : return x1
else : return xn , reverse (x1 , x2 , . . . , xn−1 ) .
gn = gn−1 + gn−2 + 1, n ≥ 3,
gn = 2fn+1 − 1, n ≥ 1, (2)
Proof.
• Base case. For n = 1, (2) becomes g1 = 1 = 2f2 − 1 = 2 − 1 which is true because
g1 = 1 and f2 = 1.
gk+1 = 2fk+2 − 1.
That is, equation (2) is true for n = k + 1, and hence the proof is complete.
3
• Induction step. It suffices to prove that (3) is true for n = k + 1. That is,
Lk+3 = fk+2 + fk+4 .
Indeed, by definition of L, the induction hypothesis and definition of f , we have
Lk+3 = Lk+2 + Lk+1 (definition of L)
= fk+1 + fk+3 + fk + fk+2 (induction hypothesis for n = k and n = k − 1)
= fk+1 + fk + fk+3 + fk+2
= fk+2 + fk+4 (definition of f ).
That is, equation (3) is true for n = k + 1, and hence the proof is complete.
Hence,
1 n 4 −n
an = ·4 + ·2 .
5 5
4
√ √ √
(b) an = an−1 + 2 an−2 with a0 = a1 = 1.
√
Solution. Set bn = an . We get b0 = b1 = 1 and bn = bn−1 + 2bn−2 .
Solve the equation:
t2 − t − 2 = 0 ⇔ t1 = −1 ∨ t2 = 2.
Then
bn = b · (−1)n + d · 2n
where b and d are constants.
To find b and d, we use the initial conditions:
( (
1
b0 = b + d = 1 b= 3
⇔ 2
b1 = −b + 2d = 1 d= 3
Then,
1 2
bn = · (−1)n + · 2n .
3 3
Hence,
2
1 2
an = b2n = · (−1)n + · 2n .
3 3
Hence, the recursive version of f is: f (1) = 2 and f (n) = 2f (n − 1) + 3 (∀n ≥ 2).
10n − 1
f (n) = , for all n ≥ 1. (4)
9
Proof.
• Base case. For n = 1, (4) becomes
10 − 1
f (1) = = 1,
9
which is true.
• Induction hypothesis. Suppose that (4) is true for all positive integers n ≤ k
(k ≥ 1). In particular,
10k − 1
f (k) = .
9
• Induction step. It suffices to prove that (4) is true for n = k + 1. That is,
10k+1 − 1
f (k + 1) = .
9
Indeed,
10k − 1 10k+1 − 1
f (k + 1) = 10f (k) + 1 = 10 +1= .
9 9
That is, equation (4) is true for n = k + 1, and hence the proof is complete.
References
1. Johnsonbaugh, R.: Discrete Mathematics - Eighth Edition. Pearson Education, New York
(2018).