4 Induction And Recursion

Discrete Structures · Unit 4 · 5 hrs

Induction and Recursion

Exam-focused notes for Induction and Recursion (Discrete Structures, CSC165): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.

Induction and Recursion in short

This chapter covers mathematical induction, the standard technique for proving a statement about every natural number, together with recursive definitions and recursive algorithms, and the technique for proving that such an algorithm computes what it claims to.

Induction and Recursion: notes

Induction

Many statements in discrete mathematics take the form "$P(n)$ holds for every integer $n \geq n_0$", for example a closed-form sum, a divisibility fact, or an inequality. Checking such a statement one integer at a time never finishes, so mathematical induction instead proves it in two finite steps that together certify every case at once: a base case anchoring the smallest value of $n$, and an inductive step showing that truth at one value forces truth at the next.

Mathematical Induction

The principle of mathematical induction proves $P(n)$ for every integer $n \geq n_0$ in two steps. The basis step shows $P(n_0)$ is true directly. The inductive step assumes the inductive hypothesis, that $P(k)$ is true for an arbitrary $k \geq n_0$, and uses it to show $P(k+1)$ is true. Once both steps are established, $P(n_0)$ is true, and it forces $P(n_0+1)$, which forces $P(n_0+2)$, and so on for every integer at or above $n_0$, exactly like an infinite line of dominoes where knocking over the first is guaranteed to knock over all the rest.

To prove that $1+2+\cdots+n = \dfrac{n(n+1)}{2}$ for every $n\geq1$: the base case $n=1$ gives left side $1$ and right side $\frac{1(2)}{2}=1$, so the formula holds. For the inductive hypothesis, assume $1+2+\cdots+k=\frac{k(k+1)}{2}$ for some $k\geq1$. For the inductive step, add $k+1$ to both sides: $$1+2+\cdots+k+(k+1) = \frac{k(k+1)}{2}+(k+1) = \frac{k(k+1)+2(k+1)}{2} = \frac{(k+1)(k+2)}{2},$$ which is exactly the claimed formula with $n$ replaced by $k+1$. Since the base case holds and the inductive step carries truth from $k$ to $k+1$, the formula holds for every $n\geq1$.

As a second example, prove that $1+2+2^2+\cdots+2^n = 2^{n+1}-1$ for every $n\geq0$. The base case $n=0$ gives left side $1$ and right side $2^1-1=1$. For the inductive hypothesis, assume $1+2+\cdots+2^k = 2^{k+1}-1$ for some $k\geq0$. For the inductive step, $$1+2+\cdots+2^k+2^{k+1} = (2^{k+1}-1)+2^{k+1} = 2\cdot2^{k+1}-1 = 2^{k+2}-1,$$ matching the claimed formula for $n=k+1$, which completes the induction.

What this unit covers

  • Induction
  • mathematical Induction
  • Strong Induction and Well Ordering
  • Induction in General
  • Recursive Definitions and Structural Induction
  • Recursive Algorithms
  • Proving Correctness of Recursive Algorithms

mathematical Induction

2081 · 5 marks

Using mathematical induction show that $5 + 2 + 5 + 8 + ... + (3n-1) = \frac{n(3n+1)}{2}$ [5]

$$5 + 2 + 5 + 8 + \cdots + (3n - 1) = \frac{n(3n+1)}{2}$$ Note: The series begins with the term for $n=1$: when $n=1$, $3(1)-1 = 2$. The leading "5" in the problem statement appears to be a typographical artifact. The series is $2, 5, 8, \ldots, (3n-1)$, which is an arithmetic progression with fi...

Open this answer on its own page →

2079 · 10 marks

A group of 8 scientist is composed of 5 chemist and 3 biologist. In how many ways can a committee of 5 be formed that has 3 chemist and 2 biologist? Using mathematical induction prove that $1^3 + 2^3 + 3^3 + ... + n^3 = (n^2(n+1)^2/4)$ for $n \geq 1$. [10]

Show solved answer

Answer

Part 1: Committee Formation

Given Data

  • Total scientists = 8 (5 chemists + 3 biologists)
  • Committee required = 5 members: exactly 3 chemists and 2 biologists

Solution

Select 3 chemists from 5: $$C(5,3) = \frac{5!}{3!,2!} = \frac{5\times 4}{2\times 1} = 10$$

Select 2 biologists from 3: $$C(3,2) = \frac{3!}{2!,1!} = 3$$

By the multiplication principle: $$\text{Total} = C(5,3)\times C(3,2) = 10 \times 3 = \boxed{30 \text{ ways}}$$


Part 2: Proof by Mathematical Induction

Claim: $$1^3 + 2^3 + \cdots + n^3 = \frac{n^2(n+1)^2}{4}, \quad n \geq 1$$

Base Case (n = 1)

  • LHS $= 1^3 = 1$
  • RHS $= \dfrac{1^2 \cdot 2^2}{4} = \dfrac{4}{4} = 1$

LHS = RHS, so the statement holds for $n = 1$. ✓

Inductive Hypothesis

Assume true for $n = k$: $$1^3 + 2^3 + \cdots + k^3 = \frac{k^2(k+1)^2}{4}$$

Inductive Step

Show true for $n = k+1$: $$1^3 + \cdots + k^3 + (k+1)^3 = \frac{k^2(k+1)^2}{4} + (k+1)^3$$

$$= \frac{k^2(k+1)^2 + 4(k+1)^3}{4} = \frac{(k+1)^2\left[k^2 + 4(k+1)\right]}{4}$$

$$= \frac{(k+1)^2(k^2 + 4k + 4)}{4} = \frac{(k+1)^2(k+2)^2}{4}$$

This matches the formula with $n = k+1$. ✓

Conclusion

By the Principle of Mathematical Induction, the formula holds for all integers $n \geq 1$: $$1^3 + 2^3 + \cdots + n^3 = \frac{n^2(n+1)^2}{4}$$

Open this answer on its own page →

2078 · 10 marks

Prove that for all integers x and y, if $x^2 + y^2$ is even then x + y is even. Using induction prove that $1^3 + 2^3 + 3^3 + ... + n^3 = n^2(n + 1)^2/4$ [10]

The contrapositive of "if x² + y² is even, then x + y is even" is: If x + y is odd, then x² + y² is odd. We prove the contrapositive. This is a valid approach because a statement and its contrapositive are logically equivalent. --- Assume x + y is odd. For the sum of two integers to be odd, one m...

Open this answer on its own page →

2076 · 5 marks

Prove that for every positive integer n≥1,n2+nn \geq 1, n^2 + nn≥1,n2+n is even integer using mathematical induction. [5]

An integer is even if it can be written in the form 2k for some integer k. Also note that: $$n^2 + n = n(n+1)$$ This is the product of two consecutive integers, which will be useful in each step. --- Substitute n = 1: $$n^2 + n = (1)^2 + (1) = 1 + 1 = 2$$ Since 2 = 2(1), which is of the form 2k, ...

Open this answer on its own page →

2075 · 5 marks

Prove that $5^n - 1$ is divisible by 4 using mathematical induction. [5]

We want to prove that 4 (5ⁿ - 1) for all positive integers n, i.e., (5ⁿ - 1) is divisible by 4. --- Substitute n = 1: $$5^1 - 1 = 5 - 1 = 4$$ Since 4 is divisible by 4, the base case holds. --- Assume the statement is true for n = k, i.e., assume: $$5^k - 1 \text{ is divisible by 4}$$ This means ...

Open this answer on its own page →

2080.1 · 10 marks

How can you use mathematical induction to prove statements? Use mathematical induction to show that sum of first n positive integer is $\frac{n(n+1)}{2}$ [10]

Mathematical induction is a proof technique used to prove that a statement P(n) is true for all positive integers n. It works in two steps: Step 1: Basis Step (Base Case) Show that the statement P(1) is true (i.e., verify the statement holds for the smallest value, usually n = 1). Step 2: Inducti...

Open this answer on its own page →

Proving Correctness of Recursive Algorithms

2081 · 5 marks

Define subset and power set. How do you prove correctness of recursive algorithm using Induction? Illustrate with an example. [5]

Show solved answer

Subset, Power Set, and Proving Correctness of Recursive Algorithms by Induction


1. Subset

A set A is called a subset of set B if every element of A is also an element of B. This is denoted as:

A ⊆ B if and only if ∀x (x ∈ A → x ∈ B)

Example: If A = {a, b} and B = {a, b, c}, then A ⊆ B.

  • The empty set (∅) is a subset of every set.
  • Every set is a subset of itself.

2. Power Set

The power set of a set S is the set of all subsets of S, including the empty set. It is denoted as P(S).

If |S| = n, then |P(S)| = 2ⁿ

Example (from notes): For S = {a, b, c, d}, the power set P(S) contains:

Subset SizeSubsets
0 elements{∅}
1 element{a}, {b}, {c}, {d}
2 elements{a,b}, {a,c}, {a,d}, {b,c}, {b,d}, {c,d}
3 elements{a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}
4 elements{a,b,c,d}

Total subsets = 1 + 4 + 6 + 4 + 1 = 16 = 2⁴ ✓


3. Proving Correctness of a Recursive Algorithm Using Induction

Mathematical induction is the standard method for proving that a recursive algorithm produces the correct result for all valid inputs.

Steps:

  1. Base Case: Show the algorithm gives the correct output for the smallest/simplest input.
  2. Inductive Hypothesis: Assume the algorithm works correctly for all inputs of size less than n (or for input n = k).
  3. Inductive Step: Show that if the algorithm works for smaller inputs (by the hypothesis), it also works correctly for input of size n (or n = k+1).

4. Illustration: Recursive Factorial Algorithm

Algorithm:

factorial(n):
    if n = 0 then
        return 1
    else
        return n * factorial(n - 1)

Claim: factorial(n) correctly computes n! for all n ≥ 0.


Proof by Mathematical Induction:

Base Case (n = 0):

The algorithm returns 1 when n = 0. By definition, 0! = 1. Therefore, the algorithm is correct for n = 0. ✓


Inductive Hypothesis:

Assume factorial(k) correctly computes k! for some arbitrary k ≥ 0. That is, assume factorial(k) returns k!.


Inductive Step (show it works for n = k + 1):

When the algorithm is called with input (k + 1):

  • Since k + 1 > 0, it executes: return (k+1) * factorial(k)
  • By the inductive hypothesis, factorial(k) returns k!
  • Therefore, the algorithm returns:

$$ (k+1) \times k! = (k+1)! $$

This is exactly the correct value of (k+1)!. ✓


Conclusion:

By the principle of mathematical induction, factorial(n) correctly computes n! for all n ≥ 0.

This demonstrates that induction mirrors the recursive structure of the algorithm: the base case handles the termination condition, and the inductive step handles the recursive call.

Open this answer on its own page →

2075 · 10 marks

Compute the values. 3 mod 4 , 7 mod 5, -5 mod 3 , 11 mod 5 and -8 mod 6Write down the recursive algorithm to find the value of bnb^nbn and prove its correctness using induction.[5+5]

(a) Computing Modular Values For an integer $a$ and positive integer $d$, we write $a \bmod d = r$ where $$a = d \cdot q + r, \qquad 0 \le r < d.$$ The remainder $r$ must be non-negative and strictly less than $d$, so for negative $a$ we take $q = \lfloor a/d \rfloor$ (the floor). --- $$3 = 4 \cd...

Open this answer on its own page →

Strong Induction and Well Ordering

2080 · 10 marks

Explain strong induction in detail. What is recursively defined function? Use mathematical induction to prove $7^{n+2} + 8^{2n+1}$ is divisible by 57.[10]

--- Strong Induction (also called the Second Principle of Mathematical Induction or Complete Induction) is a variant of mathematical induction where, to prove that a statement P(n) is true for all positive integers n, we assume that P(k) is true for ALL values from the base case up to some arbitr...

Open this answer on its own page →