Intermediate Topic 23 of 51 Algorithms
Master Theorem
Formula solving recurrences of divide-and-conquer algorithms.
How it works
The master theorem solves recurrences of the form T(n) = a T(n/b) + f(n), where a subproblems of size n/b are solved and f(n) is the cost of dividing and combining. Comparing f(n) with n to the log base b of a gives three cases: leaves dominate, work is balanced across levels, or the root dominates. This yields the asymptotic bound without expanding the recursion by hand.
Where it is used
Analyzing merge sort at Theta(n log n), binary search at Theta(log n), Karatsuba multiplication and Strassen's algorithm uses the master theorem.
Common pitfall
It does not apply when subproblems have unequal sizes, when a is not constant or when f(n) falls in the gaps between cases, for example with log factors without regularity. Misidentifying a, b or f(n) gives wrong bounds. Use the Akra-Bazzi method or a recursion tree for irregular recurrences.
Where it fits in the course
Master Theorem is topic 23 of 51 in Algorithms, rated Intermediate. It follows Divide and Conquer. The next topic is Greedy Algorithms.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Algorithms quiz.
- Explore the Growth Rates (Big-O) visualizer: Chart O(1) to O(n!) as n grows.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Algorithms quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Master Theorem?
Where do people use Master Theorem?
What is the most common mistake with Master Theorem?
What should I learn before this topic?
How can I practice it?
Is Master Theorem hard to learn?
How long does it take to learn Master Theorem?
Which topics are related to Master Theorem?
What should I study after Master Theorem?
Related topics
- Divide and Conquer (Algorithms)
- Greedy Algorithms (Algorithms)
- Timsort (Algorithms)
- Dynamic Programming (Algorithms)
- Bayes' Theorem (Math for Computing)
- Central Limit Theorem (Math for Computing)
- Rice's Theorem (Theory & Discrete Math)