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.
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]
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 answerHide 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}$$
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]
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]
2075 · 5 marks
Prove that $5^n - 1$ is divisible by 4 using mathematical induction. [5]
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]
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 answerHide 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 Size | Subsets |
|---|---|
| 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:
- Base Case: Show the algorithm gives the correct output for the smallest/simplest input.
- Inductive Hypothesis: Assume the algorithm works correctly for all inputs of size less than n (or for input n = k).
- 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.
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]
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]
Make Unit 4 stick
Practice CSC165 with flashcards & quizzes