Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
courses:cs211:winter2012:journals:mike:home [2012/03/01 04:44] – whitem12 | courses:cs211:winter2012:journals:mike:home [2012/03/01 04:56] – [Section 1: Mergesort] whitem12 | ||
---|---|---|---|
Line 50: | Line 50: | ||
===== Chapter 5 ===== | ===== Chapter 5 ===== | ||
+ | Divide and Conquer | ||
====Section 1: Mergesort==== | ====Section 1: Mergesort==== | ||
- | + | Idea: Divide a list in half until you have sorted lists (all single entries) and then merge them back together as a sorted list such that the final list is a sorted version of the initial list. Takes n steps to break down and n*log(n) steps to merge them back together. | |
+ | === Approaches === | ||
+ | Two basic ways: | ||
+ | ==Unrolling the Mergesort Recurrence== | ||
+ | Analyze the first few layers and generalize from there to unroll how the recursion takes place. | ||
+ | ==Substituting a Solution into the Mergesort Recurrence== | ||
+ | Guess what the solution is and then check it (this is good for merge sort since we know it takes n*log(n). | ||
+ | ==Partial Substitution== | ||
+ | So if you don't know the constant then you can assume it exists and then check to make sure that it turns out right in the end and then work it back up to find the actual constant involved. | ||