Professional Documents
Culture Documents
Lec 5
Lec 5
Content
Mathematical induction
Strong induction and well-ordering
Recursive definitions and structural induction
Recursive algorithms
Program correctness
Reading
Chapter 5
Triomino
2n
2n+1
2n
Algorithm Proof
Let P(n): n S
P(0) is true, otherwise 0 is the least element.
If P(k) is true, k S, then k+1 cannot belong to S, otherwise k+1
would be the least element => P(k+1) is true
Because induction, (P(0) k(P(k) → P(k+1))) → nP(n), n N,
n, n S => contradicted with the fact that S cannot be .
f is defined recursively by
f(0) = 3 // basis step
f(n+1) = 2f(n) + 3, n N
◼ an+1 = a * an, n N
E.g.,
English string ( = {a, A, b, B, …})
◼ discrete, NCTU
Binary string ( = {0, 1})
◼ 01100010
◼ If w * and x , then wx *
◼ w: string; x: symbol
T1 T2
T1 T2
// Recursive algorithm
procedure gcd(a, b: nonnegative integers with a < b)
if a = 0 then gcd(a, b) := b
else gcd(a, b) := gcd(b mod a, a)
// Iterative algorithm
procedure gcd(a, b: positive integers)
while b 0
r := a mod b; a := b; b := r
gcd(a, b) := a
and
// conditional statement