l12_recur2

L12_recur2 - 6.042/18.062J Mathematics for Computer Science Srini Devadas and Eric Lehman Lecture Notes Recurrences Recursion — breaking an

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 6.042/18.062J Mathematics for Computer Science March 17, 2005 Srini Devadas and Eric Lehman Lecture Notes Recurrences Recursion — breaking an object down into smaller objects of the same type— is a ma- jor theme in mathematics and computer science. For example, in an induction proof we establish the truth of a statement P ( n ) from the truth of the statement P ( n − 1) . In pro- gramming, a recursive algorithm solves a problem by applying itself to smaller instances of the problem. Back on the mathematical side, a recurrence equation describes the value of a function in terms of its value for smaller arguments. These various incarnations of re- cursion work together nicely. For example one might prove a recursive algorithm correct using induction or analyze its running time using a recurrence equation. In this lecture, we’ll learn how to solve a family of recurrence equations, called “linear recurrences”, that frequently arise in computer science and other disciplines. 1 The Towers of Hanoi In the Towers of Hanoi problem, there are three posts and seven disks of different sizes. Each disk has a hole through the center so that it fits on a post. At the start, all seven disks are on post #1 as shown below. The disks are arranged by size so that the smallest is on top and the largest is on the bottom. The goal is to end up with all seven disks in the same order, but on a different post. This is not trivial because of two restrictions. First, the only permitted action is removing the top disk from a post and dropping it onto another post. Second, a larger disk can never lie above a smaller disk on any post. (These rules imply, for example, that it is no fair to pick up the whole stack of disks at once and then to drop them all on another post!) Post #1 Post #2 Post #3 It is not immediately clear that a solution to this problem exists; maybe the rules are so stringent that the disks cannot all be moved to another post! 2 Recurrences One approach to this problem is to consider a simpler variant with only three disks. We can quickly exhaust the possibilities of this simpler puzzle and find a 7-move solution such as the one shown below. (The disks on each post are indicated by the numbers immediately to the right. Larger numbers correspond to larger disks.) 1 2 3 ⇒ 2 3 1 ⇒ 3 1 2 ⇒ 3 1 2 ⇒ 3 1 2 ⇒ 1 3 2 ⇒ 1 2 3 ⇒ 1 2 3 This problem was invented in 1883 by the French mathematician Edouard Lucas. In his original account, there were 64 disks of solid gold. At the beginning of time, all 64 were placed on a single post, and monks were assigned the task of moving them to another post according to the rules described above. According to legend, when the monks complete their task, the Tower will crumble and the world will end!...
View Full Document

This note was uploaded on 02/08/2011 for the course EECS 6.042 taught by Professor Dr.ericlehman during the Spring '11 term at MIT.

Page1 / 15

L12_recur2 - 6.042/18.062J Mathematics for Computer Science Srini Devadas and Eric Lehman Lecture Notes Recurrences Recursion — breaking an

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online