A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Divide and Conquer

College Depth 86 in the knowledge graph ☐ I know this ☆ Set as goal
35topics build on this
478prerequisites beneath it
See this on the map →
Recursion BasicsTime and Space Complexity+4 more→→Cache-Oblivious AlgorithmsFast Fourier Transform and Polynomial Multiplication+3 more
divide-and-conquer recursion algorithm-design master-theorem

Core Idea

Divide and conquer solves problems by recursively splitting them into smaller subproblems of the same type, solving each independently, and combining results. The paradigm has three phases: divide (split the problem), conquer (solve recursively), and combine (merge results). The Master Theorem provides a closed-form solution for recurrences of the form T(n) = aT(n/b) + f(n), covering most divide-and-conquer algorithms. Classic applications include merge sort, quicksort, and Strassen's matrix multiplication.

How It's Best Learned

Use merge sort as the canonical example. Explicitly draw the recursion tree for small inputs and verify that the work at each level sums to the predicted total. Practice applying the Master Theorem to derive complexity from recurrences.

Common Misconceptions

Explainer

You know recursion: a function that solves a problem by calling itself on smaller inputs until hitting a base case. Divide and conquer is a specific pattern of recursion with three distinct phases. First, divide the problem into smaller subproblems of the same type. Second, conquer each subproblem by solving it recursively (or directly if it's small enough). Third, combine the subproblem solutions into a solution for the original problem. The key requirement is that the subproblems are *independent* — solving one does not depend on the result of another. This independence is what distinguishes divide and conquer from dynamic programming, where subproblems overlap and share dependencies.

Merge sort is the clearest example to build intuition from. Given an unsorted array, divide it into two halves. Recursively sort each half (conquer). Then merge the two sorted halves into a single sorted array (combine). The merge step walks through both halves simultaneously, always picking the smaller element, producing a sorted result in O(n) time. The key insight is that the hard work happens in the *combine* step, not the divide step — splitting an array in half is trivial, but merging two sorted arrays is where the useful computation occurs. This is common in divide-and-conquer algorithms: the divide step is often simple, and the algorithm's character is defined by how it combines results.

Binary search, which you already know, is actually a degenerate case of divide and conquer where you only recurse on *one* subproblem (the half that might contain your target) and the combine step is trivial (just return the result). This is called decrease and conquer by some authors. True divide and conquer recurses on *all* subproblems. This distinction matters for understanding time complexity: binary search does O(1) work per level with one branch (giving O(log n) total), while merge sort does O(n) work per level with two branches (giving O(n log n) total).

The Master Theorem gives you a shortcut for analyzing divide-and-conquer recurrences of the form T(n) = aT(n/b) + f(n), where *a* is the number of subproblems, *n/b* is each subproblem's size, and f(n) is the cost of dividing and combining. The theorem compares f(n) to n^(log_b(a)): if the divide/combine work grows slower than the recursive branching, the leaves dominate; if it grows faster, the root dominates; if they match, you get a log factor. For merge sort, a = 2, b = 2, f(n) = O(n), and nlog₂2 = n, so T(n) = O(n log n). Once you internalize this framework, you can analyze any divide-and-conquer algorithm's complexity by simply identifying a, b, and f(n) and checking which case applies.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → Defining and Calling Functions → Functions: Decomposing Problems → Function Parameters and Argument Passing → Return Values → Variable Scope → Introduction to Classes → Objects and Instances → Methods and Attributes → Algorithm Design Basics → Asymptotic Notation: Big-O, Big-Omega, Big-Theta → Big-O Notation and Complexity Analysis → Time and Space Complexity → Binary Search → Divide and Conquer

Longest path: 87 steps · 478 total prerequisite topics

Prerequisites (6)

Leads To (5)