MCS-211 · Block 1 Unit 2

Some Pre-requisites and Asymptotic Bounds

Section 4 of 8

Block 1 · Unit 2Some Pre-requisites and Asymptotic Bounds17 min · Section 4 of 8

2.4Mathematical Induction

Covers IGNOU MCS-211 §2.4

How can you prove that a formula holds for every natural number, when you can only ever check finitely many cases? Mathematical induction is the answer, and it is the main proof tool in algorithm analysis: it proves sum formulas, recurrence solutions and the correctness of loops and recursive algorithms.

The idea

Writing an induction proof

  1. State P(n)P(n) clearly.
  2. Base case. Check P(n0)P(n_0) by direct calculation (usually n0=1n_0 = 1 or 00).
  3. Induction hypothesis. “Assume P(k)P(k) is true for some arbitrary k≥n0k \ge n_0.” Write out what that means.
  4. Inductive step. Using the hypothesis, prove P(k+1)P(k+1). Usually: split the (k+1)(k+1) case into “the kk case” plus one extra term, replace the kk case using the hypothesis, and simplify to the required form.
  5. Conclusion. “By induction, P(n)P(n) holds for all n≥n0n \ge n_0.”

Induction and algorithms

Induction is how we prove algorithms correct. For a loop, we prove a loop invariant — a statement true before every iteration — by induction on the number of iterations. For a recursive algorithm, we assume the recursive calls on smaller inputs are correct (the hypothesis) and show the current call is correct. For example, factorial(n) returns n⋅n \cdot factorial(n−1n-1); if factorial(n−1n-1) correctly returns (n−1)!(n-1)!, then factorial(n) returns n⋅(n−1)!=n!n \cdot (n-1)! = n!.

Key takeaways

  • Induction = base case + inductive step P(k)⇒P(k+1)P(k) \Rightarrow P(k+1) for arbitrary kk.
  • The hypothesis assumes P(k)P(k) for one arbitrary kk, not for all nn.
  • Standard results: ∑i=n(n+1)2\sum i = \frac{n(n+1)}{2}, ∑i2=n(n+1)(2n+1)6\sum i^2 = \frac{n(n+1)(2n+1)}{6}, ∑i=0n2i=2n+1−1\sum_{i=0}^{n} 2^i = 2^{n+1} - 1.
  • Induction proves loop invariants and the correctness of recursive algorithms.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

In an induction proof starting at n=1n = 1, which step proves the statement for n=1n = 1?

Show answer

Answer: A. The base case

The base case checks the first value directly. The hypothesis is an assumption, not a proof of anything.

Question 2 · multiple choice

What does the induction hypothesis assume?

Show answer

Answer: C. P(k)P(k) is true for some arbitrary k≥n0k \ge n_0.

We assume the statement for one arbitrary k and prove it for k + 1. Assuming it for all n would be circular.

Question 3 · multiple choice

In the inductive step for ∑i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}, what is k(k+1)2+(k+1)\frac{k(k+1)}{2} + (k+1) equal to?

Show answer

Answer: C. (k+1)(k+2)2\frac{(k+1)(k+2)}{2}

Put both over 2: [k(k+1) + 2(k+1)]/2 = (k+1)(k+2)/2.

Question 4 · multiple choice

A “proof” shows P(k)⇒P(k+1)P(k) \Rightarrow P(k+1) for all kk but never checks a base case. What can we conclude?

Show answer

Answer: C. Nothing: without a base case the statement may be false for every nn.

The chain of implications needs a first true domino. “n = n + 1” satisfies the step but is never true.

Question 5 · multiple choice

Check ∑i=0n2i=2n+1−1\sum_{i=0}^{n} 2^i = 2^{n+1} - 1 for n=4n = 4.

Show answer

Answer: B. 31=3131 = 31

1 + 2 + 4 + 8 + 16 = 31 and 2⁵ − 1 = 31. 15 = 2⁴ − 1 is the value for n = 3.

Question 6 · short answer

Prove by induction that 1+3+5+⋯+(2n−1)=n21 + 3 + 5 + \dots + (2n - 1) = n^2 for all n≥1n \ge 1.

Show worked answer

Base case (n = 1): left = 1, right = 1² = 1, true. Induction hypothesis: assume 1 + 3 + … + (2k − 1) = k² for some k ≥ 1. Inductive step: 1 + 3 + … + (2k − 1) + (2(k + 1) − 1) = k² + (2k + 1) = (k + 1)², which is the statement for n = k + 1. Conclusion: by induction, the sum of the first n odd numbers is n² for all n ≥ 1.

↑ ↓ move↵ openTab switch type