Professional Documents
Culture Documents
and Design
By
Proof
Basis step: Since, A1 A2 A1 A2 true for n = 2
Induction step: Assume the result is true n = k and then prove for n = k+1.
k 1 k
A j A j Ak 1
j 1 j 1
k
A j Ak 1
j 1
k
A j Ak 1 (by induction hypothesis)
j 1
k 1
Aj
j 1
Proposition:
Suppose a0, a1, a2, … is defined as follows:
a0 = 1, a1 = 2, a2 = 3,
ak = ak-1 + ak-2 + ak-3 for all integers k ≥ 3.
Then an ≤ 2n for all integers n≥0. P(n)
Proof (by strong induction)
Basis step:
The statement is true
for n = 0: a0 = 1 ≤ 1 = 20 P(0)
for n = 1: a1 = 2 ≤ 2 = 21 P(1)
for n = 2: a2 = 3 ≤ 4 = 22 P(2)
Inductive step:
For any k > 2, assume P(i) is true for all i with 0 ≤ i < k,
i.e., ai ≤ 2i for all 0 ≤ i < k (1)
Show that
P(k) is true: ak ≤ 2k (2)
Now consider
ak = ak-1 + ak-2 + ak-3
≤ 2k-1 + 2k-2 + 2k-3 based on (1)
≤ 20 + 21 + … + 2k-3 + 2k-2 + 2k-1
= 2k - 1 ≤ 2k
Thus, P(n) is true by strong mathematical induction.
Hence it proves the result
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Existence
Induction of Binary
Examples (4/4)Integer Representation
3.3 Mathematical Inducti
Theorem
Given any positive integer n, there exists a unique representation
of n in the form:
n = cr.2r + cr-1.2r-1 + . . . + c1.21 + c0
• Where r is non-negative integer
• cr.= 1, and cj = 0 or 1, j = 0, 1, 2, . . . , r-1
Proof (by strong induction)
Let P(n) be the statement that n can be written in the form
n = cr.2r + cr-1.2r-1 + . . . + c1.21 + c0
Basis step:
If n = 1, then n = cr.2r = c0, where r = 0, and c0 = 1
Hence the statement is true for n = 1, i.e. P(1) is true
Inductive Hypothesis:
Let us suppose that statement is true for all i, 1 ≤ i < k,
i = ck.2k + ck-1.2k-1 + . . . + c1.21 + c0
• cr.= 1, and cj = 0 or 1, j = 0, 1, 2, . . . , r-1
Show that
Now we prove that statement is true for k
Case 1
Suppose k is even, k/2 is an integer and k/2 < k, hence
k/2 = cr.2r + cr-1.2r-1 + . . . + c1.21 + c0
where r is non-negative integer and
cr.= 1, and cj = 0 or 1, j = 0, 1, 2, . . . , r-1
Uniqueness
Now we prove that n has a unique representation
n = cr.2r + cr-1.2r-1 + . . . + c1.21 + c0
• Where r is non-negative integer
• cr.= 1, and cj = 0 or 1, j = 0, 1, 2, . . . , r-1
On contrary, suppose that n has two different
representations, i.e.
n = cr.2r + cr-1.2r-1 + . . . + c1.21 + c0 (1) and
n = br.2r + br-1.2r-1 + . . . + b1.21 + b0 (2)
Now subtract (2) from (1) we get
0 = (br- cr)2r + (br-1- cr-1).2r-1 + . . . + (b0- c0)
br = cr, br-1= cr-1, . . ., b1 = c1.and b0 = c0 , proved
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
More Complicated Example
1
Problem
Let f0 x , and fn 1 f0 fn , n 0.
2 x
• Find an expression for fn and prove it by induction.
Solution
1
Since f 0 and f n 1 f o f 0 therefore
2 x
1 1 2 x
f1 ( x) f 0 f 0 (x) f 0 ( )
2 x 1 3 2x
2
2 x
2 x 1 3 2x
And, f 2 ( x) f 0 f1 (x) f 0 ( )
3 2x 2 x 4 3x
2
3 2x
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
More Complicated Example
3 2x
And, f 3 ( x) f 0 f 2 (x) f 0 ( )
4 3x
1 4 3x
3 2x 5 4x
2
4 3x
And so on
n (n 1) x
f n ( x) f 0 f n -1 (x) f 0 ( )
(n 1) nx
1 (n 1) nx
n (n 1) x (n 2) (n 1) x
2
(n 1) nx
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
More Complicated Example
Now generalized function is
(n 1) nx
f n ( x)
(n 2) (n 1) x
By definition: f n 1 f 0 f n f k 1 f 0 f k k 0
(k 1) kx 1
f k 1 ( x) f 0 ( )
(k 2) (k 1) x (k 1) kx
2
(k 2) (k 1) x
(k 2) (k 1) x
After simplification, f k 1 ( x) , proved.
(k 3) (k 2) x
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design