0% found this document useful (0 votes)
47 views111 pages

Chapter 5. Induction and Recursion

This document is the introduction to Chapter 5 of a textbook. It discusses mathematical induction, recursive definitions, recursive algorithms and Fibonacci numbers. The chapter will cover proving statements using induction, defining functions recursively, algorithms that call themselves recursively, and properties of the Fibonacci sequence defined by Fn=Fn-1 +Fn-2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views111 pages

Chapter 5. Induction and Recursion

This document is the introduction to Chapter 5 of a textbook. It discusses mathematical induction, recursive definitions, recursive algorithms and Fibonacci numbers. The chapter will cover proving statements using induction, defining functions recursively, algorithms that call themselves recursively, and properties of the Fibonacci sequence defined by Fn=Fn-1 +Fn-2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 111

Mathematical Induction Recursive Recursive Algorithms Problems

Chapter 5. Induction and Recursion

Lai Văn Phút

Ngày 1 tháng 5 năm 2023

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Contents

1. Mathematical Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Contents

1. Mathematical Induction
2. Recursive Definitions

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Contents

1. Mathematical Induction
2. Recursive Definitions
3. Recursive Algorithms

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

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:
• BASIS STEP. We verify that P (1) is true.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

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:
• BASIS 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.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

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:
• BASIS 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.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

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:
• BASIS 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.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

n(n + 1)
1. Prove that 1 + 2 + 3 + .... + n − 1 + n =
2

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

n(n + 1)
1. Prove that 1 + 2 + 3 + .... + n − 1 + n =
2
2. Conjecture a formula for the sum of the first n positive
odd integers. Then prove your conjecture using
mathematical induction.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

n(n + 1)
1. Prove that 1 + 2 + 3 + .... + n − 1 + n =
2
2. Conjecture a formula for the sum of the first n positive
odd integers. Then prove your conjecture using
mathematical induction.
3. 20 + 21 + .... + 2n = 2n+1 − 1

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

To prove P(n) is true for all positive integers n, where P(n) is


a propositional function, two steps are performed:
• Basis step: Verifying P (1) is true

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

To prove P(n) is true for all positive integers n, where P(n) is


a propositional function, two steps are performed:
• Basis step: Verifying P (1) is true
• Inductive step: Show
[P (1) ∧ P (2) ∧ ... ∧ P (k )] → P (k + 1) is true for all k > 0

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

To prove P(n) is true for all positive integers n, where P(n) is


a propositional function, two steps are performed:
• Basis step: Verifying P (1) is true
• Inductive step: Show
[P (1) ∧ P (2) ∧ ... ∧ P (k )] → P (k + 1) is true for all k > 0

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

To prove P(n) is true for all positive integers n, where P(n) is


a propositional function, two steps are performed:
• Basis step: Verifying P (1) is true
• Inductive step: Show
[P (1) ∧ P (2) ∧ ... ∧ P (k )] → P (k + 1) is true for all k > 0
Example. Prove that if n is an integer greater than 1, then
n can be written as the product of primes.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13
1. Find F8 .

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13
1. Find F8 .
2. Find F20

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13
1. Find F8 .
2. Find F20

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13
1. Find F8 .
2. Find F20 if F18 = 2584, F19 = 4181.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Fibonacci numbers:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

n 1 2 3 4 5 6 7
Fn 1 1 2 3 5 8 13
1. Find F8 .
2. Find F20 if F18 = 2584, F19 = 4181.
Ingeneral, F1 = F2 = 1, Fn = Fn−1 + Fn−2 , n ≥ 3

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Introduction

Sometimes, it is difficult to define an object explicitly.


However, it may be easy to define this object in terms of
itself. This process is called recursion.
Lai Văn Phút Chapter 5. Induction and Recursion
Mathematical Induction Recursive Recursive Algorithms Problems

Recursive definition of Fibonacci numbers

Procedure Fibo(n:positive integer)


if n = 1 or n = 2
return 1
else
return Fibo(n − 1)+Fibo(n − 2)

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive definition of Fibonacci numbers

Procedure Fibo(n:positive integer)


if n = 1 or n = 2
return 1
else
return Fibo(n − 1)+Fibo(n − 2)
What is output value if input n = 5?

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive definition of Fibonacci numbers

Procedure Fibo(n:positive integer)


if n = 1 or n = 2
return 1
else
return Fibo(n − 1)+Fibo(n − 2)
What is output value if input n = 5?
• Basis step F1 = 1, F2 = 1

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive definition of Fibonacci numbers

Procedure Fibo(n:positive integer)


if n = 1 or n = 2
return 1
else
return Fibo(n − 1)+Fibo(n − 2)
What is output value if input n = 5?
• Basis step F1 = 1, F2 = 1
• recursive step Fn = Fn−1 + Fn−2 , n ≥ 3.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Functions (hàm đệ quy)

We use two steps to define a function with the set of


nonnegative integers as its domain:
1. BASIS STEP: Specify the value of the function at zero.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Functions (hàm đệ quy)

We use two steps to define a function with the set of


nonnegative integers as its domain:
1. BASIS STEP: Specify the value of the function at zero.
2. RECURSIVE STEP: Give a rule for finding its value at an
integer from its values at smaller assessment integers.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Give an algorithm to find pseudo-random numbers if


x0 = 1, xn+1 = (3xn + 17) mod 22

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Procedure sum(n:n ≥ 1, integer)


if n = 1
return 1
else
return sum(n − 1)+n

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Procedure sum(n:n ≥ 1, integer)


if n = 1
return 1
else
return sum(n − 1)+n
If input n = 4, what is the value of output?

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Procedure sum(n:n ≥ 1, integer)


if n = 1
return 5
else
return sum(n − 1)

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Procedure sum(n:n ≥ 1, integer)


if n = 1
return 5
else
return sum(n − 1)
If input n = 4, what is the value of output?

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Example.

Find the recursive algorithm of f (n) = 5n + 1, n ≥ 1

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...
3. f (n) = 1 + 2 + 3 + ... + n, n = 1, 2, 3, ...

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...
3. f (n) = 1 + 2 + 3 + ... + n, n = 1, 2, 3, ...
4. f (n) = 2022, ∀n

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...
3. f (n) = 1 + 2 + 3 + ... + n, n = 1, 2, 3, ...
4. f (n) = 2022, ∀n
5. .

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...
3. f (n) = 1 + 2 + 3 + ... + n, n = 1, 2, 3, ...
4. f (n) = 2022, ∀n
5. .

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Exercises

1. an = 5n − 2, n = 1, 2, 3...?
2. an = n, n = 1, 2, 3...
3. f (n) = 1 + 2 + 3 + ... + n, n = 1, 2, 3, ...
4. f (n) = 2022, ∀n
5. .

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

1. Give the recursive definition of a n (where a is a


nonzero real number and n is a nonnegative integer).

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

1. Give the recursive definition of a n (where a is a


nonzero real number and n is a nonnegative integer).
2. Suppose that f is defined recursively by
f (0) = 3, f (n + 1) = 2f (n) + 3. Find f (1), f (2), f (3) and
f (4).

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

1. Give the recursive definition of a n (where a is a


nonzero real number and n is a nonnegative integer).
2. Suppose that f is defined recursively by
f (0) = 3, f (n + 1) = 2f (n) + 3. Find f (1), f (2), f (3) and
f (4).
n
3. Give a recursive definition of ∑ ak
k =0

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.
Examples. Consider the subset S of the set of integers
recursively defined by
• Basis step. 3 ∈ S

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.
Examples. Consider the subset S of the set of integers
recursively defined by
• Basis step. 3 ∈ S
• Recursive step. If x ∈ S and y ∈ S, then x + y ∈ S.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.
Examples. Consider the subset S of the set of integers
recursively defined by
• Basis step. 3 ∈ S
• Recursive step. If x ∈ S and y ∈ S, then x + y ∈ S.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursively Defined Sets (tập đệ quy)

Recursive definitions of sets have two parts


• Basis step. An initial collection of elements is specified.
• Recursive step. Rules for forming new elements in the
set from those already known to be in the set are
provided.
Examples. Consider the subset S of the set of integers
recursively defined by
• Basis step. 3 ∈ S
• Recursive step. If x ∈ S and y ∈ S, then x + y ∈ S.
→ S = {3, 6, 9, 12, 15, 18, 21, ...}

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Find S if
a. 1 is in S, if x is in S then x + 1 and x + 2 are in S,

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Find S if
a. 1 is in S, if x is in S then x + 1 and x + 2 are in S,
b. 1 is in S, if x is in S then x + 3 is in S,

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Find S if
a. 1 is in S, if x is in S then x + 1 and x + 2 are in S,
b. 1 is in S, if x is in S then x + 3 is in S,
c. 1, 2 are in S, if x is in S then x + 3 is in S.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Give a recursive definition of each of these sets.


a. A = {2, 5, 8, 11, 14, ...},

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Give a recursive definition of each of these sets.


a. A = {2, 5, 8, 11, 14, ...},
b. B = {..., −5, −1, 3, 7, 11, ...},

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Examples.

Give a recursive definition of each of these sets.


a. A = {2, 5, 8, 11, 14, ...},
b. B = {..., −5, −1, 3, 7, 11, ...},
c. C = {3, 12, 48, 192, 768, ...}.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!
0! = 1

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!
0! = 1
1! = 1.0! = 1.1 = 1

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!
0! = 1
1! = 1.0! = 1.1 = 1
2! = 2.1! = 2.1 = 2

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!
0! = 1
1! = 1.0! = 1.1 = 1
2! = 2.1! = 2.1 = 2
3! = 3.2! = 3.2 = 6

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Definition

An algorithm is called recursive if it solves a problem by


reducing it to an instance of the same problem with
smaller input.
Examples. Find 4!
0! = 1
1! = 1.0! = 1.1 = 1
2! = 2.1! = 2.1 = 2
3! = 3.2! = 3.2 = 6
4! = 4.3! = 4.6 = 24

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing n!

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing n!

Example. Using the algorithm to compute 5!

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing a n

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing a n

Example. Find output value if a = 3, n = 4

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing gcd(a,b)

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing gcd(a,b)

Example. Find output value if input a = 5, b = 8

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithm for Computing gcd(a,b)

Example. Find output value if input a = 5, b = 8

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Modular Exponentiation

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Modular Exponentiation

Example. Find 25 mod 3

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Linear Search Algorithm

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Linear Search Algorithm

Example. List all the steps used to search for 9 in the


sequence 2, 3, 4, 5, 6, 8, 9, 11

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Binary Search Algorithm

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Binary Search Algorithm

Example. To search for 19 in the list


1, 2, 3, 5, 6, 7, 8, 10, 12, 13, 15, 16, 18, 19, 20, 22

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort


Example. Use the merge sort to put the terms of the list
8, 2, 4, 6, 9, 7, 10, 1, 5, 3 in increasing order.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort


Example. Use the merge sort to put the terms of the list
8, 2, 4, 6, 9, 7, 10, 1, 5, 3 in increasing order.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort


Example. Use the merge sort to put the terms of the list
8, 2, 4, 6, 9, 7, 10, 1, 5, 3 in increasing order.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort


Example. Use the merge sort to put the terms of the list
8, 2, 4, 6, 9, 7, 10, 1, 5, 3 in increasing order.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort


Example. Use the merge sort to put the terms of the list
8, 2, 4, 6, 9, 7, 10, 1, 5, 3 in increasing order.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists


Example. Merging the Two Sorted Lists 2, 3, 5, 6 and 1, 4.

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Merge Sort two sorted lists

Theorem. The number of comparisons needed to merge


sort a list with n elements is O (nlogn).

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Mathematical Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Mathematical Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Mathematical Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Strong Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Definitions and Structural Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Definitions and Structural Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Definitions and Structural Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Definitions and Structural Induction

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithms

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithms

Lai Văn Phút Chapter 5. Induction and Recursion


Mathematical Induction Recursive Recursive Algorithms Problems

Recursive Algorithms

Lai Văn Phút Chapter 5. Induction and Recursion

You might also like