CSCE 411 Lecture 5
Jump to navigation
Jump to search
« previous | Wednesday, September 5, 2012 | next »
Example Limit Superior
Therefore
Divide and Conquer
- Divide a problem into subproblems
- Recursively solve subproblems
- Combine solutions to subproblems to get solution to original problem
Example: Merge-sort
- Divide the input in half
- Recursively sort the two halves (basis is a sequence with 1 key)
- Combine two sorted subsequences by merging them
Recurrence Relation
How long does Merge-sort take?
Let be the worst-case time on a sequence of keys.
If , then (constant)
If , then (2 × time of solving each half and then the merge)
Two ways to solve:
- Expand several times, guess pattern, and try to prove by induction. (hard!)
- Master theorem
Using the master theorem, and . Therefore,
Master Theorem
(See Master Theorem→)
Given a recursive function (recurrence relation) of the form
Let . This represents the number of "leaf operations" in the divide-and-conquer tree
- If then
- If then
- If then
Other D&C Algorithms
- Mathematics
- Converting Binary to Decimal
- Integer Multiplication
- Matrix Multiplication
- Matrix Inversion
- Fast Fourier Transform