Professional Documents
Culture Documents
———o0o———
DISCRETE MATHEMATIS
Hanoi, 2022
1 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content
2 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content
3 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.1 Mathematical Induction (Quy nạp toán học)
Principle of Mathematical
Induction
To prove that P (n) is true for all
positive integers n, where P (n) is a
propositional function, we complete
two steps:
Basic step: We verify that P (1)
is true.
Inductive step: We show that
the conditional statement
P (k) → P (k + 1) is true for all
positive integers k.
4 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.1 Mathematical Induction
Example
n(n + 1)
Prove that 1 + 2 + 3 + . . . + n = ∀n > 0.
2
Conjecture a formula for the sum of the first n positive odd
integers. Then prove your conjecture using mathematical
induction.
Prove that 2n < n! ∀n > 3.
5 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content
6 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.1 Mathematical Induction (Quy nạp toán học)
7 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
Solution
Let P (n) : n can be written as the product of primes.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
Solution
Let P (n) : n can be written as the product of primes.
Basic step: P (2) : 2 = 2 ⇒ P (2) true.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
Solution
Let P (n) : n can be written as the product of primes.
Basic step: P (2) : 2 = 2 ⇒ P (2) true.
Inductive step: Assumption: P (j) true for all positive 2 ≤ j ≤ k.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
Solution
Let P (n) : n can be written as the product of primes.
Basic step: P (2) : 2 = 2 ⇒ P (2) true.
Inductive step: Assumption: P (j) true for all positive 2 ≤ j ≤ k.
Case k + 1 is a prime ⇒ P (k + 1) true.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.2 Strong Induction
Example
Prove that if n is an integer greater than 1, then n can be written as
the product of primes.
Solution
Let P (n) : n can be written as the product of primes.
Basic step: P (2) : 2 = 2 ⇒ P (2) true.
Inductive step: Assumption: P (j) true for all positive 2 ≤ j ≤ k.
Case k + 1 is a prime ⇒ P (k + 1) true.
Case k + 1 is a composite ⇒ k + 1 = ab, 2 ≤ a ≤ b ≤ k. ⇒ P (k + 1)
is true.
8 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content
9 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursion: Introduction
Introduction
Objects/ functions may be difficultly defined
10 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursion: Introduction
Introduction
Objects/ functions may be difficultly defined
Define an object/function in terms of itself
Example
(
1 nếu n = 0
2n =
2.2n−1 nếu n > 0
n
X 0 nếu n = 0
i= n−1
P
i=0
n + i nếu n > 0
i=0
10 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursively Defined Functions
Example
n
P
Give the recursive definition of ai .
i=0
11 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursively Defined Functions
Example
n
P
Give the recursive definition of ai .
i=0
Solution
0
P
Basis step: ai = a0
i=0
n
P n−1
P
inductive step: ai = an + ai .
i=0 i=0
11 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursively Defined Functions
Definition
Fibonacci numbers
(
1 nếu n = 0, 1
f (n) =
f (n − 1) + f (n − 2) nếu n > 1
12 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Recursively Defined Functions
Definition
Fibonacci numbers
(
1 nếu n = 0, 1
f (n) =
f (n − 1) + f (n − 2) nếu n > 1
Example
Calculate the number of divisions used by the Euclidean algorithm:
gcd(65, 23), gcd(327, 9)
12 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content
13 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.4 Recursive Algorithms
Definition
An algorithm is called recursive if it solves a problem by reducing it to
an instance of the same problem with smaller input.
14 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.4 Recursive Algorithms
Definition
An algorithm is called recursive if it solves a problem by reducing it to
an instance of the same problem with smaller input.
Example
Recursive algorithm for computing n!
14 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.4 Recursive Algorithms
Definition
An algorithm is called recursive if it solves a problem by reducing it to
an instance of the same problem with smaller input.
Example
Recursive algorithm for computing n!
14 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.4 Recursive Algorithms
Example
Recursive algorithm for computing an
15 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.4 Recursive Algorithms
Example
Recursive algorithm for computing an
15 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion