This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Chapter 5 Divide and Conquer Divideandconquer refers to a class of algorithmic techniques in which one breaks the input into several parts, solves the problem in each part recursively, and then combines the solutions to these subproblems into an overall solution. In many cases, it can be a simple and powerful method. Analyzing the running time of a divideandconquer algorithm generally involves solving a recurrence relation that bounds the running time recursively in terms of the running time on smaller instances. We begin the chapter with a general discussion of recurrence relations, illustrating how they arise in the analysis and describing methods for working out upper bounds from them. We then illustrate the use of divideandconquer with applications to a number of different domains: computing a distance function on different rankings of a set of objects; finding the closest pair of points in the plane; multiplying two integers; and smoothing a noisy signal. Divideandconquer will also come up in subsequent chapters, since it is a method that often works well when combined with other algorithm design techniques; for example, we will see it combined with dynamic programming to produce a spaceeﬃcient solution to sequence alignment, and combined with randomization to yield a simple and eﬃcient algorithm for computing the median of a set of numbers. One thing to note about many settings in which divideandconquer is applied, including these, is that the natural bruteforce algorithm may already be polynomialtime, and the divideandconquer strategy is serving to reduce the running time to a lower polynomial. This is in contrast to most of the problems in the previous chapter, for example, where bruteforce was exponential and the goal in designing a more sophisticated algorithm was to achieve any kind of polynomial running time. For example, we discussed in Chapter 2 that the natural bruteforce algorithm for finding the closest pair among n points in the plane would simply measure all Θ( n 2 ) distances, for a (polynomial) running time of Θ( n 2 ). Using divideandconquer, we will improve the running time to O ( n log n ). At a high level, then, the overall theme of this chapter is the same as what we’ve been seeing earlier: that 197 198 CHAPTER 5. DIVIDE AND CONQUER improving on bruteforce search is a fundamental conceptual hurdle in solving a problem eﬃciently, and the design of sophisticated algorithms can achieve this. The difference is simply that the distinction between bruteforce search and an improved solution here will not always be the distinction between exponential and polynomial. 5.1 A First Recurrence: The Mergesort Algorithm To motivate the general approach to analyzing divideandconquer algorithms, we begin with the Mergesort algorithm. We discussed the Mergesort algorithm brieﬂy in Chapter 2, when we surveyed common running times for algorithms. Mergesort sorts a given list of numbers by first dividing them into two equal halves, sorting each half separately by recursion, and...
View
Full
Document
This note was uploaded on 02/18/2010 for the course CSB 1208204834 taught by Professor N/a during the Spring '10 term at École Normale Supérieure.
 Spring '10
 N/A

Click to edit the document details