Master the recursive paradigm of breaking problems into smaller subproblems, solving them independently, and combining their solutions. Learn the Master Theorem and analyze recursive algorithms.
Break the problem into smaller subproblems of the same type
Solve subproblems recursively (base case solves directly)
Merge solutions of subproblems to solve original problem
Merge sort, Quick sort, Binary search
Matrix multiplication, FFT, Karatsuba
Closest pair, Convex hull, Voronoi diagram
Maximum subarray, Selection problems
T(n) = a·T(n/b) + f(n)
where a ≥ 1, b > 1, and f(n) is asymptotically positive
f(n) = O(n^(log_b(a) - ε)) for some ε > 0
T(n) = Θ(n^(log_b(a)))
T(n) = 2T(n/2) + O(1) → T(n) = Θ(n)
Work is dominated by leaves of recursion tree
f(n) = Θ(n^(log_b(a)) × log^k(n)) for some k ≥ 0
T(n) = Θ(n^(log_b(a)) × log^(k+1)(n))
T(n) = 2T(n/2) + O(n) → T(n) = Θ(n log n)
Work is balanced between levels
f(n) = Ω(n^(log_b(a) + ε)) and regularity condition
T(n) = Θ(f(n))
T(n) = 2T(n/2) + O(n²) → T(n) = Θ(n²)
Work is dominated by root of recursion tree
Optimal solution contains optimal solutions to subproblems
No overlapping subproblems (unlike DP)
Can split problem quickly into roughly equal parts
Can efficiently merge subproblem solutions
Poor pivot choice in quicksort → O(n²) worst case
If combining is too costly, D&C may not help
Should use DP instead of D&C for efficiency
Deep recursion may exceed stack limits
Algorithm | Recurrence | Master Theorem Case | Time Complexity |
---|---|---|---|
Binary Search | T(n) = T(n/2) + O(1) | Case 1 | O(log n) |
Merge Sort | T(n) = 2T(n/2) + O(n) | Case 2 | O(n log n) |
Strassen | T(n) = 7T(n/2) + O(n²) | Case 1 | O(n^2.807) |
Karatsuba | T(n) = 3T(n/2) + O(n) | Case 1 | O(n^1.585) |
Max Subarray | T(n) = 2T(n/2) + O(n) | Case 2 | O(n log n) |
Visualize recursive algorithms and understand how they break down problems