You are on page 1of 15

Advanced Algorithms Analysis

and Design

By

Dr. Nazir Ahmad Zafar

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Lecture No 5

Strong Mathematical Induction


(Proving, Validation and Verification, etc.)

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Today Covered
• Generalization of Demargon’s Laws
• Strong Mathematical Induction
• Converting problems to be proved using strong
mathematical induction
• Proving Problems using Strong Induction
• Fibonacci Problem and its Sequence
• Construction of Mathematical Model
• Explicit Formula Computing Fibonacci Numbers
• Recursive Algorithms
• Conclusion
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Proof: Generalized
Induction Demargon’s Law by Induction
Examples (4/4) 3.3 Mathematical Inducti

Aj   Aj when n2, i.e.,  A1  A2  ...  An  A1  A2  ...  An 


n n
Prove 
j 1
j 1

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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Postage Ticket: Again More Steps in Basis
Prove that postage ticket of amount  12 cents can be formed
using only 4 cent and 5 cent stamps.
Proof
Let P(n)  n cents can be formed using only 4 and 5 cent
P(n)  n = 4s + 5t s  0, and t  0  n  12
Basis : P(12) is true, since 12 = 4  3;
P(13) is true, since 13 = 4  2 + 5  1;
P(14) is true, since 14 = 4  1 + 5  2;
P(15) is true, since 15 = 5  3;
Inductive : Assume P(12), P(13), …, P(k) are true.
Now prove for P(k + 1) (k3  12)
Suppose k-3 = 4  s + 5  t.
Then k +1 = 4  (s + 1) + 5  t. true for n = k + 1.
By Strong Induction, P(n) is true if n  Z and n 12.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Proving
Induction a Property
Examples (4/4) of a Sequence 3.3 Mathematical Inducti

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)

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Proving
Induction a Property
Examples (4/4) of a Sequence 3.3 Mathematical Inducti

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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Existence
Induction of Binary
Examples (4/4)Integer Representation
3.3 Mathematical Inducti

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

Dr Nazir A. Zafar Advanced Algorithms Analysis and Design


Existence
Induction of Binary
Examples (4/4)Integer Representation
3.3 Mathematical Inducti

k = 2.cr.2r + 2.cr-1.2r-1 + . . . + 2.c1.21 + 2.c0


k = cr.2r+1 + cr-1.2r + . . . + c1.22 + c0.21, true
which is the required form
Case 2
Let k ≥ 3, is odd, (k-1)/2 is an integer and 1 ≤ (k-1)/2 < k,
(k-1)/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
Now, k – 1 = cr.2r+1 + cr-1.2r + . . . + c1.22 + c0.21
And, k = cr.2r+1 + cr-1.2r + . . . + c1.22 + c0.21 + 1, true
• Hence by strong mathematical induction, P(n) is true
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Induction Examples Uniqueness
(4/4) 3.3 Mathematical Inducti

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

Now we prove this guess by mathematical Induction


Basis case: take n = 0
1
f0  , which is true
2 x
Inductive hypothesis: assume that statement is true n = k
(k  1)  kx
f k ( x) 
(k  2)  (k  1) x
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
More Complicated Example
Claim: Now we have to prove that statement is true n = k + 1
(k  1  1)  (k  1) x (k  2)  (k  1) x
f k 1 ( x)  
(k  1  2)  (k  1  1) x (k  3)  (k  2) 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

You might also like