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 moreCache-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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraConditional StatementsDefining and Calling FunctionsFunctions: Decomposing ProblemsFunction Parameters and Argument PassingReturn ValuesVariable ScopeIntroduction to ClassesObjects and InstancesMethods and AttributesAlgorithm Design BasicsAsymptotic Notation: Big-O, Big-Omega, Big-ThetaBig-O Notation and Complexity AnalysisTime and Space ComplexityBinary SearchDivide and Conquer

Longest path: 87 steps · 478 total prerequisite topics

Prerequisites (6)

Leads To (5)