MIT6_042JF10_lec10

MIT6_042JF10_lec10 - 10 “mcs-ftl” — 2010/9/8 — 0:40...

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 Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 10 “mcs-ftl” — 2010/9/8 — 0:40 — page 283 — #289 Recurrences A recurrence describes a sequence of numbers. Early terms are specified explic- itly and later terms are expressed as a function of their predecessors. As a trivial example, this recurrence describes the sequence 1, 2, 3, etc.: T 1 D 1 T n D T n 1 C 1 (for n 2 ) : Here, the first term is defined to be 1 and each subsequent term is one more than its predecessor. Recurrences turn out to be a powerful tool. In this chapter, we’ll emphasize using recurrences to analyze the performance of recursive algorithms. However, recur- rences have other applications in computer science as well, such as enumeration of structures and analysis of random processes. And, as we saw in Section 9.4 , they also arise in the analysis of problems in the physical sciences. A recurrence in isolation is not a very useful description of a sequence. One can not easily answer simple questions such as, “What is the hundredth term?” or “What is the asymptotic growth rate?” So one typically wants to solve a recurrence; that is, to find a closed-form expression for the n th term. We’ll first introduce two general solving techniques: guess-and-verify and plug- and-chug. These methods are applicable to every recurrence, but their success re- quires a flash of insight—sometimes an unrealistically brilliant flash. So we’ll also introduce two big classes of recurrences, linear and divide-and-conquer, that often come up in computer science. Essentially all recurrences in these two classes are solvable using cookbook techniques; you follow the recipe and get the answer. A drawback is that calculation replaces insight. The “Aha!” moment that is essential in the guess-and-verify and plug-and-chug methods is replaced by a “Huh” at the end of a cookbook procedure. At the end of the chapter, we’ll develop rules of thumb to help you assess many recurrences without any calculation. These rules can help you distinguish promis- ing approaches from bad ideas early in the process of designing an algorithm. Recurrences are one aspect of a broad theme in computer science: reducing a big problem to progressively smaller problems until easy base cases are reached. This same idea underlies both induction proofs and recursive algorithms. As we’ll see, all three ideas snap together nicely. For example, one might describe the running time of a recursive algorithm with a recurrence and use induction to verify the solution. 284 “mcs-ftl” — 2010/9/8 — 0:40 — page 284 — #290 Chapter 10 Recurrences Figure 10.1 The initial configuration of the disks in the Towers of Hanoi problem. 10.1 The Towers of Hanoi According to legend, there is a temple in Hanoi with three posts and 64 gold disks of different sizes. Each disk has a hole through the center so that it fits on a post....
View Full Document

{[ snackBarMessage ]}

Page1 / 31

MIT6_042JF10_lec10 - 10 “mcs-ftl” — 2010/9/8 — 0:40...

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