Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

ECOM 2311- Discrete Mathematics

Chapter # 5 : Induction and Recursion

Fall, 2013/2014

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 1 / 23


Outline

1 Mathematical Induction

2 Strong Induction and Well-Ordering

3 Recursive Definitions

4 Recursive Algorithms

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 2 / 23


Mathematical Induction
Introduction

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.

Expressed as a rule of inference, this proof technique can be stated


as (P(1) ∧ ∀k(P(k) → P(k + 1))) → ∀nP(n).
The steps of the mathematical induction proof:
Show that P(1) is true.
Show that P(k) → P(k + 1) is true for every positive integer k. To
prove that this conditional statement is true for every positive integer
k, we need to show that P(k + 1) cannot be false when P(k) is true.
This can be accomplished by assuming that P(k) is true and showing
that under this hypothesis P(k + 1) must also be true.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 3 / 23


Mathematical Induction
Examples

Example: Show that if n is a positive integer, then


1 + 2 + · · · + n = n(n+1)
2
We must do two things to prove that P(n) is true for n = 1, 2, 3, · · ·
Namely,we must show that P(1) is true and that the conditional
statement P(k) implies P(k + 1) is true for k = 1, 2, 3, · · · .
1·(1+1)
BASIS STEP: P(1) is true, because 1 = 2
INDUCTIVE STEP: For the inductive hypothesis we assume that
P(k) holds for an arbitrary positive integer k. That is, we assume
that 1 + 2 + · · · + k = k(k+1)
2

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 4 / 23


Mathematical Induction
Examples

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 5 / 23


Mathematical Induction
Examples

Example: Use mathematical induction to show that


1 + 2 + 22 + · · · + 2n = 2n+1 − 1 for n = 0, 1, 2, · · ·
Let P(n) be the proposition that 1 + 2 + 22 + · · · + 2n = 2n+1 − 1
for the integer n.
BASIS STEP: P(0) is true because 20 = 1 = 21 − 1.
INDUCTIVE STEP: For the inductive hypothesis we assume that
P(k) holds for an arbitrary nonnegative integer k. That is, we
assume that 1 + 2 + 22 + + 2k = 2(k+1) − 1
We need to prove that
1 + 2 + 22 + + 2k + 2(k+1) = 2(k+1)+1 − 1 = 2(k+2) − 1.
Given the hypothesis p(k)., we see that

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 6 / 23


Mathematical Induction
Examples

Example: Use mathematical induction to show that n < 2n for all


positive integers n
Let P(n) be the proposition that n < 2n for the positive integer n.
BASIS STEP: P(1) is true because 1 < 21 = 2.
INDUCTIVE STEP: For the inductive hypothesis we assume that
P(k) holds for an arbitrary positive integer k. That is, we assume
that k < 2k
We need to prove that k + 1 < 2k+1 .
Given the hypothesis p(k)., we see that
k + 1 < 2k + 1 ≤ 2k + 1 ≤ 2k + 2k = 2 · 2k = 2k+1 .

Exercise:
Use mathematical induction to prove that 2n < n! for every integer n
with n ≥ 4.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 7 / 23


Mathematical Induction
Examples

Example: Use mathematical induction to prove that n3 − n is divisible


by 3 whenever n is a positive integer.
Let P(n) be the proposition that ”n3 − n is divisible by 3” for the
positive integer n.
BASIS STEP: P(1) is true because 13 − 1 = 0 is divisible by 3.
INDUCTIVE STEP: For the inductive hypothesis we assume that
P(k) holds for an arbitrary positive integer k. That is, we assume
that k 3 − k is divisible by 3.
We need to prove that (k + 1)3 − (k + 1) is divisible by 3.
(k +1)3 −(k +1) = (k 3 +3k 2 +3k +1)−(k +1) = (k 3 −k)+3(k 2 +k).
The first term is divisible by 3 form the hypothesis and the second
term is a multiple of 3 and hence is divisible by 3. Accordingly,
(k 3 − k) + 3(k 2 + k) is divisible by 3.
Exercise: Use mathematical induction to prove that 7n+2 + 82n+1 is
divisible by 57 for every nonnegative integer n.
ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 8 / 23
Mathematical Induction
Examples

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 9 / 23


Mathematical Induction
Examples

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 10 / 23


Strong Induction
Introduction

Strong 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(1) ∧ P(2) ∧ · · · ∧ P(k)] → P(k + 1) is true for all positive integers k.

Strong induction is a more flexible proof technique than the


mathematical induction.
Strong induction is sometimes called the second principle of
mathematical induction or complete induction.
The mathematical induction and strong induction are equivalent.
That is, each can be shown to be a valid proof technique assuming
that the other is valid.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 11 / 23


Strong Induction
Examples

Example: Show that if n is an integer greater than 1, then n can be


written as the product of primes.
Let P(n) be the proposition that ∀n > 1, n can be written as the
product of primes.
BASIS STEP: P(2) is true because 2 can be written as the product
of a single prime number 2.
INDUCTIVE STEP: Suppose that every integer between 2 and k
can be written as the product of one or more primes.
We need to show that k + 1 can be written as a product of primes.
Case 1: k + 1 is prime. Then it is the product of one prime.
Case 2: k+1 is composite. Then k+1 can be written as ab, where a
and b are integers such that 1 < a, b < k + 1. By the induction
hypothesis, a can be written as a product of primes p1 p2 · · · pi and b
can be written as a product of primes q1 q2 · · · qj . So then k + 1
can be written as the product of primes p1 p2 · · · pi q1 q2 · · · qj .
ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 12 / 23
Recursive Definitions
Recursively Defined Functions

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


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

Ex. 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).
f (1) = 2f (0) + 3 = 2 · 3 + 3 = 9,
f (2) = 2f (1) + 3 = 2 · 9 + 3 = 21,
f (3) = 2f (2) + 3 = 2 · 21 + 3 = 45,
f (4) = 2f (3) + 3 = 2 · 45 + 3 = 93.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 13 / 23


Recursive Definitions
Recursively Defined Functions

EX. Give a recursive definition of an , where a is a nonzero real number


and n is a nonnegative integer.

First a0 is specified, namely, a0 = 1.


Then the rule for finding an+1 from an , namely, an+1 = a · an , for
n = 0, 1, 2, 3, · · · , is given.
These equations uniquely define an for all nonnegative integers n.

EX. Give a recursive definition of nk=0 ak .


P

The first part of the recursive definition is 0k=0 ak = a0 .


P

The second part is n+1


P Pn
k=0 ak = ( k=0 ak ) + an+1

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 14 / 23


Recursive Definitions
Recursively Defined Functions

Recursive definitions of sets have two parts, a basis step and a recursive
step. In the basis step, an initial collection of elements is specified. In
the recursive step, rules for forming new elements in the set from those
already known to be in the set are provided.
EX. 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..
The new elements found to be in S are 3 by the basis step, 3 + 3 =
6 at the first application of the recursive step
3 + 6 = 6 + 3 = 9 and 6 + 6 = 12 at the second application of the
recursive step, and so on.
Note that S is the set of all positive multiples of 3.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 15 / 23


Recursive Algorithms
Introduction

An algorithm is called recursive if it solves a problem by reducing it to an


instance of the same problem with smaller input.
EX. Give a recursive algorithm for computing n!, where n is a
nonnegative integer.

First, we use the recursive step to write 4! = 4 · 3!. We then use the
recursive step repeatedly to write 3! = 3 · 2!, 2! = 2 · 1!, and 1! = 1 · 0!.
Inserting the value of 0! = 1, and working back through the steps, we see
that 1! = 1 · 1 = 1, 2! = 2 · 1! = 2, 3! = 3 · 2! = 3 · 2 = 6, and
4! = 4 · 3! = 4 · 6 = 24.
ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 16 / 23
Recursive Algorithms
Introduction

EX. Give a recursive algorithm for computing an , where a is a nonzero


real number and n is a nonnegative integer.
We can base a recursive algorithm on the recursive definition of an . This
definition states that an+1 = a · an for n > 0 and the initial condition
a0 = 1. To find an , successively use the recursive step to reduce the
exponent until it becomes zero.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 17 / 23


Recursive Algorithms
Recursion and Iteration

A recursive definition expresses the value of a function at a positive


integer in terms of the values of the function at smaller integers.
This means that we can devise a recursive algorithm to evaluate a
recursively defined function at a positive integer.
Instead of successively reducing the computation to the evaluation
of the function at smaller integers, we can start with the value of
the function at one or more integers, the base cases, and
successively apply the recursive definition to find the values of the
function at successive larger integers.
Such a procedure is called iterative.
Often an iterative approach for the evaluation of a recursively
defined sequence requires much less computation than a procedure
using recursion

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 18 / 23


Recursive Algorithms
Recursion and Iteration

The iterative and recursive procedures for finding the nth Fibonacci
number.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 19 / 23


Recursive Algorithms
The Merge Sort

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

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 20 / 23


Recursive Algorithms
The Merge Sort

EX. Merge the two lists 2, 3, 5, 6 and 1, 4.

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 21 / 23


Recursive Algorithms
The Merge Sort

Two sorted lists with m elements and n elements can be merged into a
sorted list using no more than m + n - 1 comparisons.

The number of comparisons needed to merge sort a list with n elements


is O(n log n).

ECOM 2311- Discrete Mathematics - Ch.5 Dr. Musbah Shaat 22 / 23


Homework [due 26th of Nov].
From the text book, Section 5.1, page 329
Questions: Q4, Q6, Q16, Q22 and Q32.
From the text book, Section 5.3, page 357
Questions: Q6[Parts a,c,d], Q8[Parts a,b], Q24[Parts a,b], Q26[Part a].
From the text book, Section 5.4, page 370
Questions: Q8, Q16, Q44, Q46[Part a] and Q49[Very important].

End of Chapter # 5

You might also like