You are on page 1of 26

FPT UNIVERSITY

———o0o———

Chapter 4: Induction and Recursion

DISCRETE MATHEMATIS

Lecture: Dr. Nguyen Kieu Linh

Hanoi, 2022

1 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content

1 4.1 Mathematical Induction

2 4.2 Strong Induction

3 4.3 Recursive Definitions and Structural Induction

4 4.4 Recursive Algorithms

2 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
Content

1 4.1 Mathematical Induction

2 4.2 Strong Induction

3 4.3 Recursive Definitions and Structural Induction

4 4.4 Recursive Algorithms

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

1 4.1 Mathematical Induction

2 4.2 Strong Induction

3 4.3 Recursive Definitions and Structural Induction

4 4.4 Recursive Algorithms

6 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion
4.1 Mathematical Induction (Quy nạp toán học)

Principle of Strong Induction


To prove that P (n) is true for all positive integers n, two steps are
performed:
Basic step: Verifying that P (1) is true.
Inductive step: Show [P (1) ∧ P (2) ∧ . . . ∧ P (k)] → P (k + 1) is
true for all k > 0.

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

1 4.1 Mathematical Induction

2 4.2 Strong Induction

3 4.3 Recursive Definitions and Structural Induction

4 4.4 Recursive Algorithms

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

Theorem (Lamé’s theorem)


Let a and b be positive integers with a ≥ b. Then the number of
divisions used by the Euclidean algorithm to find gcd(a, b) is less than
or equal to five times the number of decimal digits in b.

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

1 4.1 Mathematical Induction

2 4.2 Strong Induction

3 4.3 Recursive Definitions and Structural Induction

4 4.4 Recursive Algorithms

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!

Algorithm 1 A 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

Algorithm 2 A Recursive Algorithm for Computing an

15 / 15
Dr. Nguyen Kieu Linh Chapter 4: Induction and Recursion

You might also like