Data Structure Lect10
Data Structure Lect10
Data Structure Lect10
Lecture 10
Topics
Mathematical Induction
Suppose that we have an infinite ladder, as shown in next slide, and we want to
know whether we can reach every step on this ladder. We know two things:
1. We can reach the first rung of the ladder.
2. If we can reach a particular rung of the ladder, then we can reach the next
rung. Can we conclude that we can reach every rung?
By (1), we know that we can reach the first rung of the ladder. Moreover,
because we can reach the first rung,
by (2), we can also reach the second rung; it is the next rung after the first rung.
Applying (2) again, because we can reach the second rung, we can also reach the
third rung.
Climbing an Infinite Ladder
Example of Dominoes
Mathematical Induction
For example, after 100 uses of (2), we know that we can reach the 101st rung.
But can we conclude that we are able to reach every rung of this infinite ladder?
The answer is yes, something we can verify using an important proof technique
called mathematical induction.
That is, we can show that P(n) is true for every positive integer n, where P (n) is
the statement that we can reach the nth rung of the ladder.
Uses of Induction
Proves the results about the Complexity of Algorithm
To prove that P (n) is true for all positive integers n, where P (n) is a
propositional function, we complete two steps:
𝑛
𝑗=0 arj = a + ar + ar2 +···+ arn = arn+1 − a when r ≠ 1,
r−1
where n is a nonnegative integer.
Solution: To prove this formula using mathematical induction, let P (n) be the
statement that the sum of the first n + 1 terms of a geometric progression in this
formula is correct.
BASIS STEP: P(0) is true, because
ar0+1 − a = ar − a = a (r − 1) = a.
r−1 r−1 r−1
Inductive Step
The inductive hypothesis is the statement that P (k) is true, where k is an
arbitrary nonnegative integer. That is, P (k) is the statement that
a + ar + ar2 +···+ ark = ark+1 − a
r−1
To complete the inductive step we must show that if P (k) is true, then P (k + 1)
is also true. To show that this is the case, we first add ark+1 to both sides of the
equality asserted by P (k). We find that
a + ar + ar2 +···+ ark + ark+1 = ark+1 − a + ark+1
r−1
Rewriting the right-hand side of this equation shows that
ark+1 − a + ark+1 = ark+1 − a + ark+2 − ark+1
r−1 r−1 r−1
= ark+2 − a
r−1
Continued
Combining these last two equations gives
a + ar + ar2 +···+ ark + ark+1 = ark+2 − a
r−1
This shows that if the inductive hypothesis P (k) is true, then P (k + 1) must
also be true. This completes the inductive argument.
Sum of All positive Odd Intergers
Sum of the first n positive odd integers is nk, that is,
1 + 3 + 5 +··+ (2n − 1) = nk
BASIS STEP:
P (1) states that the sum of the first one odd positive integer is 12. This is true
because the sum of the first odd positive integer is 1. The basis step is complete.
INDUCTIVE STEP: To complete the inductive step we must show that the
proposition P (k) → P (k + 1) is true for every positive integer k. To do this, we
first assume the inductive hypothesis
1 + 3 + 5 +··+ (2n − 1) = nk
1+ 3 + 5 +···+ (2k − 1) = k2.
Continued
1 + 3 + 5 +···+ (2k − 1) + (2k + 1) = (k + 1) 2.