This unit has already used divide-and-conquer three times — mergesort and Strassen's algorithm in Topic 1, and quickselect in Topic 2 — without naming the shared template explicitly. This lesson names it: divide the problem into smaller independent subproblems of the same type, conquer each recursively (or solve directly if small enough), and combine the sub-solutions into a solution for the original problem. Recognising this three-step shape in a new problem is often the fastest route to an efficient algorithm — this lesson also distinguishes the "recurse into all subproblems" pattern (mergesort) from the "recurse into only one" pattern (quickselect), since the two give qualitatively different recurrence shapes.
In this lesson
- Learning objectives
- The template
- Two shapes: recurse into all, versus recurse into one
- Recognising the pattern in a new problem
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or explore the curriculum.