Design divide-and-conquer algorithms and bound them with the master theorem
8 steps · about 3 h 20 min · Intermediate
- Learn the divide, conquer, combine pattern (article, Khan Academy, 10 min)
A gentle introduction to the three steps with merge sort.
- Survey where divide and conquer applies (article, Wikipedia, 15 min)
Lists classic uses and implementation issues such as recursion depth.
- Bound recurrences with the master theorem (article, Wikipedia, 20 min)
Gives the three cases for T(n) = aT(n/b) + f(n) with examples.
- Watch divide and conquer on convex hull and medians (video, MIT OpenCourseWare, 1 h 20 min)
MIT lecture applying the method to two non-trivial problems.
- Multiply large numbers faster with Karatsuba (article, Wikipedia, 15 min)
Shows how saving one recursive call changes the exponent.
- Apply the same trick to matrix multiplication (article, Wikipedia, 15 min)
Seven products instead of eight gives a sub-cubic algorithm.
- Find the closest pair of points in n log n (article, Wikipedia, 15 min)
A geometric problem where the combine step is the clever part.
- Implement closest pair of points (tutorial, cp-algorithms, 30 min)
Full implementation with the strip argument explained.