Master Theorem

Data Structures & Algorithms 2nd Semester

What is the Master Theorem?

The Master Theorem helps you find the time complexity of many recursive algorithms of the form:

Where:

  • → number of recursive calls
  • → size reduction in each recursive call
  • → cost outside the recursive calls (e.g., sorting, merging)

Purpose

Use Master Theorem to directly find the Big-O time complexity without full recursion tree expansion.


Three Cases of Master Theorem

Compare with :

CaseConditionResult
Case 1, for some
Case 2
Case 3, and regularity condition holds

What is ?

It’s the cost of the recursion tree (total work across all levels). Compare this with to decide which case applies.


Examples

Example 1

  • , ,
  • Case 2


Example 2

  • , ,
  • Case 1


Example 3

  • , ,
  • , and satisfies the regularity condition → Case 3


Summary

Compare with :

CaseIf is…Then
1Smaller
2Equal
3Larger + regular