Master Theorem Form
General form for analyzing divide-and-conquer recurrences.
Formula
Variables
Example
Solves many recursive runtimes
How it works
This recurrence describes a problem that splits into a subproblems, each of size n/b, and then spends f(n) time doing the non-recursive work such as dividing the input and combining the results. It works because many divide-and-conquer algorithms build a recursion tree with the same branching pattern at each level, so the total time can be estimated by comparing the work done across all levels. The Master Theorem gives a fast way to decide whether the recursion is dominated by the branching, the combining work, or a balance between the two.
When to use it
Use this form when analyzing recursive divide-and-conquer algorithms like mergesort, Karatsuba-style multiplication, or recursive search/partition algorithms where the input is split into equal-sized pieces. It is most useful when the recurrence matches exact or near-exact equal subproblem sizes and the extra work can be expressed as a simple function of n.
Worked example, step by step
Solve T(n) = 2T(n/2) + n
Step 1: Identify the parameters: a = 2, b = 2, f(n) = n
Step 2: Compute n^(log_b a) = n^(log_2 2) = n^1 = n
Step 3: Compare f(n) with n^(log_b a): both are n, so they match
Step 4: By the balanced case of the Master Theorem, T(n) = Θ(n log n)
Final answer: T(n) = Θ(n log n)
Common mistakes to avoid
- Forgetting that a is the number of subproblems, not the number of recursive calls including base cases
- Using the theorem when subproblem sizes are not equal to n/b, or when the recurrence is not in the required form
- Comparing f(n) to n^(log_b a) incorrectly, especially when logarithms or lower-order terms are involved
Did You Know?
The Master Theorem instantly reveals the runtime of most divide-and-conquer algorithms.
Share this formula
More in Computer Science
View allGustafson’s Law
IntermediateIdeal scaled-workload speedup when more processors allow a larger parallel task in the same elapsed time. Here s is the serial fraction of the parallel execution time, not the single-processor fraction used in Amdahl’s law.
Hick–Hyman Law (Equal Choices)
IntermediateModels choice reaction time for n equally likely alternatives (n ≥ 1). This information-theoretic form assumes comparable, practised stimulus–response choices; it is not a universal law of menu browsing.
Fitts’s Law (Shannon Form)
IntermediateAn empirical model of aimed movement time: farther or narrower targets generally take longer to reach. Use D ≥ 0, W > 0 and fitted coefficients for the device and task.
Shannon Entropy
AdvancedAverage information content of a random source (bits).
Master Theorem (form)
AdvancedAnalyzes running time of divide-and-conquer algorithms.
Hamming Distance
AdvancedNumber of positions at which two strings differ.