{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ch5 - Chapter 5 Divide and Conquer Divide-and-conquer...

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

Unformatted text preview: Chapter 5 Divide and Conquer Divide-and-conquer 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 sub-problems into an overall solution. In many cases, it can be a simple and powerful method. Analyzing the running time of a divide-and-conquer 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 divide-and-conquer 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. Divide-and-conquer 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 space-eﬃ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 divide-and-conquer is applied, including these, is that the natural brute-force algorithm may already be polynomial-time, and the divide-and-conquer 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 brute-force 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 brute-force 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 divide-and-conquer, 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 brute-force 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 brute-force 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 divide-and-conquer 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

{[ snackBarMessage ]}

### Page1 / 40

ch5 - Chapter 5 Divide and Conquer Divide-and-conquer...

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

View Full Document
Ask a homework question - tutors are online