divide and conquer
Divide and conquer is an algorithm design technique that solves a problem by splitting it into smaller subproblems of the same kind, solving each one, and combining their answers into a solution for the whole. The subproblems are usually solved recursively, splitting again until each piece is small enough to solve directly.
A divide-and-conquer algorithm works in three steps:
- Divide: Break the problem into two or more smaller, independent subproblems, often by splitting the input in half.
- Conquer: Solve each subproblem recursively, or directly once it reaches a base case.
- Combine: Merge the subproblem solutions into a solution for the original problem.
Step through merge sort on eight numbers below to watch each range get divided down to single items, conquered as base cases, and combined back into sorted order:
Classic algorithms differ in where the hard work happens. Merge sort splits its input trivially and does most of its work while merging the sorted halves. Quicksort puts the effort into partitioning before the recursive calls, so its combine step is nearly free.
Binary search is a borderline case. It keeps only one half and ignores the other, so some authors call it decrease and conquer instead.
The cost of a divide-and-conquer algorithm is usually written as a recurrence. For merge sort, T(n) = 2T(n/2) + O(n) says that sorting n items takes two half-size sorts plus linear merging work, which gives O(n log n) time. The master theorem solves many recurrences of this shape.
Since the subproblems are independent, they can run in parallel on separate processors. Other well-known applications include Karatsuba multiplication, Strassen’s matrix multiplication, and the fast Fourier transform (FFT). When subproblems overlap and repeat, dynamic programming stores their results instead of solving them again.
Related Resources
Tutorial
Sorting Algorithms in Python
In this tutorial, you'll learn all about five different sorting algorithms in Python from both a theoretical and a practical standpoint. You'll also learn several related and important concepts, including Big O notation and recursion.
For additional information on related topics, take a look at the following resources:
- Introduction to Sorting Algorithms in Python (Course)
- Recursion in Python: An Introduction (Tutorial)
- How to Do a Binary Search in Python (Tutorial)
- Recursion in Python (Course)
- Creating a Binary Search in Python (Course)
- Sorting Algorithms in Python (Quiz)
- Recursion in Python: An Introduction (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Martin Breuss • Updated Nov. 24, 2026