Advanced Algorithms Analysis and Design: by Dr. Nazir Ahmad Zafar
Advanced Algorithms Analysis and Design: by Dr. Nazir Ahmad Zafar
and Design
By
Mathematical Induction
i 1 i 1
Proof :
Let P(n) n can be written as the product of primes.
Basis : P(2) is true, since 2 is the first prime number
Inductive : Assume that the statement is true for n = k, i.e.
P(2), P(3), …, P(k) can be written as product of primes.
Prove that: true for n = k, i.e. P(k + 1) is product of
primes.
Case 1 : k + 1 is prime, then nothing to prove
Case 2 : k + 1 is composite, then
k + 1 = xy, where 2 x y < k+1
Inductive hypothesis, a and b are product of primes.
Hence
Dr Nazir A. Zafar P(k+1) can be written as product of primes.
Advanced Algorithms Analysis and Design
Any Amount Limited Coins: More Steps in Basis
Statement
Show that any amount in cents ≥ 8 cents can be obtained
using 3 cents and 5 cents coins only.
Proof
We have to prove that, amount = 3.m + 5.n, m 0, n 0
Basis Step
This time check for a five particular values:
8 = 1.3 + 1.5
9 = 3.3
10 = 2.5
11 = 2.3 + 1.5
12 = 4.3
Now we generalize it?
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Any Amount Limited Coins : More Steps in Basis
Let P(n) be the statement that:
“n cents can be obtained using 3 and 5 cents”.
Inductive Hypothesis
We want to show that
P(k) is true P(k+1), k ≥ 8