Download presentation
Presentation is loading. Please wait.
Published byMelissa Evans Modified over 9 years ago
2
RMIT University; Taylor's College1 Lecture 6 To apply the Principle of Mathematical Induction To solve the Towers of Hanoi puzzle To define a recurrence relation
3
RMIT University; Taylor's College2 Mathematical Induction Suppose we have a mathematical proposition, P(n), about some integers n. We want to know if P(n) is true for every integer n, from a starting point onwards.
4
RMIT University; Taylor's College3 Mathematical Induction Example: Prove that n! > 2 n is true for all in positive integer n Is this sometimes true, never true, always true after a certain point, or what? Check some values: n!2n2n n = 011 n = 112 n = 224 n = 368 n = 42416 n = 512032 At this stage, n! seems to be streaking ahead of 2 n at a great rate. How could we prove n! > 2 n ? The idea is to use Proof by Induction.
5
RMIT University; Taylor's College4 Proof by Induction: 3 Steps 1.Base step: With a starting point n 0, Verify that P(n 0 ) is true. 2.Inductive step: Assume that P(k) is true, prove that P(k + 1) is also true. 3.Conclusion: Declare that P(n) is true for every integer n ≥ n 0
6
RMIT University; Taylor's College5 Example: Prove by induction that n! > 2 n for all n ≥ 4.
7
6 Conclusion: n! > 2 n for all n ≥ 4.
8
7
9
8
10
RMIT University; Taylor's College9
11
10 The Towers of Hanoi We need to move all n discs to Pole 3. But we can only move 1 disc at a time, and a disc must never be placed on a smaller disc. Theorem: This can be solved for all n ≥ 1 Proof: We can use proof by induction
12
RMIT University; Taylor's College11 The Towers of Hanoi: Proof Base step Suppose we have 1 disc. Pick it up and put it on Pole 3 Inductive step Suppose we can move (k – 1) discs. ----- (*) We want to show we can move k discs. Given k discs, leave the big one at the bottom. Move the other (k – 1) to Pole 2 instead of Pole 3. (We know this can be done, by the inductive hypothesis (*)) Move the big disc to Pole 3. Move the other stack from Pole 2 to Pole 3 (Again, we know this can be done, by (*).) We’ve moved the stack of k discs! Conclusion For all n, the problem can be solved.
13
RMIT University; Taylor's College12 The Towers of Hanoi How many moves (1 disc at a time) are needed to get the stack of n discs from Pole 1 to Pole 3? Let this number be f n. So f 1 = 1. (That is, if we only have 1 disc then a single move takes it to Pole 3.) Let’s look at the inductive proof that the puzzle can always be solved. When n = k, f k moves are needed. So what happens when n = k + 1? The number of moves needed is f k+1, but this can be expressed in terms of f k. It takes f k moves to get the top k discs to Pole 2, then 1 move to get the bottom disc to Pole 3, and then f k moves to get the stack of k discs from Pole 2 and put it on top of the biggest disc which is now on Pole 3.
14
RMIT University; Taylor's College13 The Towers of Hanoi So f k+1 = f k + 1 + f k, i.e. f k + 1 = 2f k + 1 This equation is an example of a recurrence relation, where each value of a function can be determined from previous values (assuming that we know some initial values). Using n instead of k, we have f n+1 = 2f n + 1 with initial condition f 1 = 1.
15
RMIT University; Taylor's College14 The Towers of Hanoi We can then construct the following partial table. nfnfn 11 23 37 415 531 663 f 2 = 2f 1 + 1 = 2 + 1 =3 f 3 = 2f 2 + 1 = 6 + 1 = 7
16
RMIT University; Taylor's College15 The Towers of Hanoi But suppose we want to know how many moves are needed to shift 100 discs. We would need to compute all the values from f 7 up to f 99, and then use f 100 = 2f 99 + 1 to get the value of f 100. Clearly it would be better if we had a formula for f n which only depended on n, rather than on earlier values of the function. Such a formula is called a solution to the recurrence relation. We won’t give a general method for solving recurrence relations, but rather we’ll look at how to obtain a solution for this particular example.
17
RMIT University; Taylor's College16 The Towers of Hanoi Do the values in the second column of the table look familiar? If not, let’s add 1 to every value and also put in some more rows. 1023 511 255 127 63 31 15 7 3 1 fnfn 1024 512 256 128 64 32 16 8 4 2 f n + 1 6 5 8 7 19 9 4 3 2 1 n Now it should be clear that the new last column consists of all the powers of 2 with positive exponent. Specifically, f n + 1 = 2 n. Subtracting 1 from both sides gives f n = 2 n – 1. It can be formally proved that this formula gives the correct answer. (We omit the details.)
18
RMIT University; Taylor's College17 The Towers of Hanoi Our reasoning here is an example of inductive reasoning, where we study enough examples to be able to hypothesize a general result. Note that f 100 = 2 100 – 1, which is a rather big number! 2 64 – 1 = 18, 446, 744, 073, 709, 551, 615 moves!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.