This is an old revision of the document!


Chapter 5 - Divide and Conquer

For a divide and conquer algorithm, we break the input into several parts and solve each part recursively. We then combine all solutions into an overall solution. To figure out the running time of a divide and conquer algorithm, we look at the recurrence relation, which is based on the number of times we recursively call the algorithm. Generally for a divide and conquer algorithm, the brute force method will run in some polynomial time, and the divide and conquer method will reduce that time to a lower polynomial.

Readability: 8/10

5.1 - A First Recurrence: The Mergesort Algorithm

Mergesort is a method used to sort two lists of values. We divide the list in half and sort each half using recursion, and finally we combine the results in linear time. We get the recurrence relation T(n) ≤ 2T(n/2)+cn for n>2, and T(2)≤c for the base case. There are two ways to solve the recurrence, unrolling the algorithm or starting with a guess. Unrolling the recursion involves looking at the running time for the first levels until we see a pattern. Starting with a guess and substituting, we use induction to find the solution. Also, a “partial” substitution can be used, where we leave our constants as variables and try to figure them out later.

Readability: 5/10 because of the difficult math

5.2 - Further Recurrence Relations

courses/cs211/winter2011/journals/david/chapter5.1299045076.txt.gz · Last modified: 2011/03/02 05:51 by margoliesd
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0