SlideShare a Scribd company logo
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Slides by Christopher M. Bourke
Instructor: Berthe Y. Choueiry
Spring 2006
Computer Science & Engineering 235
Introduction to Discrete Mathematics
1 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem I
When analyzing algorithms, recall that we only care about the
asymptotic behavior.
Recursive algorithms are no different. Rather than solve exactly
the recurrence relation associated with the cost of an
algorithm, it is enough to give an asymptotic characterization.
The main tool for doing this is the master theorem.
2 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem II
Theorem (Master Theorem)
Let T(n) be a monotonically increasing function that satisfies
T(n) = aT(n
b ) + f(n)
T(1) = c
where a ≥ 1, b ≥ 2, c > 0. If f(n) ∈ Θ(nd) where d ≥ 0, then
T(n) =



Θ(nd) if a < bd
Θ(nd log n) if a = bd
Θ(nlogb a) if a > bd
3 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Pitfalls
You cannot use the Master Theorem if
T(n) is not monotone, ex: T(n) = sin n
f(n) is not a polynomial, ex: T(n) = 2T(n
2 ) + 2n
b cannot be expressed as a constant, ex: T(n) = T(
√
n)
Note here, that the Master Theorem does not solve a
recurrence relation.
Does the base case remain a concern?
4 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a =
b =
d =
Therefore which condition?
5 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a = 1
b =
d =
Therefore which condition?
6 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a = 1
b = 2
d =
Therefore which condition?
7 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a = 1
b = 2
d = 2
Therefore which condition?
8 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a = 1
b = 2
d = 2
Therefore which condition?
Since 1 < 22, case 1 applies.
9 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 1
Let T(n) = T n
2 + 1
2 n2 + n. What are the parameters?
a = 1
b = 2
d = 2
Therefore which condition?
Since 1 < 22, case 1 applies.
Thus we conclude that
T(n) ∈ Θ(nd
) = Θ(n2
)
10 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a =
b =
d =
Therefore which condition?
11 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a = 2
b =
d =
Therefore which condition?
12 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a = 2
b = 4
d =
Therefore which condition?
13 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a = 2
b = 4
d = 1
2
Therefore which condition?
14 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a = 2
b = 4
d = 1
2
Therefore which condition?
Since 2 = 4
1
2 , case 2 applies.
15 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 2
Let T(n) = 2T n
4 +
√
n + 42. What are the parameters?
a = 2
b = 4
d = 1
2
Therefore which condition?
Since 2 = 4
1
2 , case 2 applies.
Thus we conclude that
T(n) ∈ Θ(nd
log n) = Θ(
√
n log n)
16 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a =
b =
d =
Therefore which condition?
17 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b =
d =
Therefore which condition?
18 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b = 2
d =
Therefore which condition?
19 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b = 2
d = 1
Therefore which condition?
20 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b = 2
d = 1
Therefore which condition?
Since 3 > 21, case 3 applies.
21 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b = 2
d = 1
Therefore which condition?
Since 3 > 21, case 3 applies. Thus we conclude that
T(n) ∈ Θ(nlogb a
) = Θ(nlog2 3
)
22 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
Master Theorem
Example 3
Let T(n) = 3T n
2 + 3
4 n + 1. What are the parameters?
a = 3
b = 2
d = 1
Therefore which condition?
Since 3 > 21, case 3 applies. Thus we conclude that
T(n) ∈ Θ(nlogb a
) = Θ(nlog2 3
)
Note that log2 3 ≈ 1.5849 . . .. Can we say that
T(n) ∈ Θ(n1.5849) ?
23 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
“Fourth” Condition
Recall that we cannot use the Master Theorem if f(n) (the
non-recursive cost) is not polynomial.
There is a limited 4-th condition of the Master Theorem that
allows us to consider polylogarithmic functions.
Corollary
If f(n) ∈ Θ(nlogb a logk
n) for some k ≥ 0 then
T(n) ∈ Θ(nlogb a
logk+1
n)
This final condition is fairly limited and we present it merely for
completeness.
24 / 25
Master
Theorem
CSE235
Introduction
Pitfalls
Examples
4th Condition
“Fourth” Condition
Example
Say that we have the following recurrence relation:
T(n) = 2T
n
2
+ n log n
Clearly, a = 2, b = 2 but f(n) is not a polynomial. However,
f(n) ∈ Θ(n log n)
for k = 1, therefore, by the 4-th case of the Master Theorem
we can say that
T(n) ∈ Θ(n log2
n)
25 / 25

More Related Content

PDF
Recurrence relation solutions
PPT
Recursion tree method
PPTX
Stressen's matrix multiplication
PPTX
Solving recurrences
PPT
Time complexity
PPTX
Matrix chain multiplication
PPT
Graph algorithm
PPTX
NP completeness
Recurrence relation solutions
Recursion tree method
Stressen's matrix multiplication
Solving recurrences
Time complexity
Matrix chain multiplication
Graph algorithm
NP completeness

What's hot (20)

PDF
Daa notes 1
PPT
Master method theorem
PPT
Np cooks theorem
PPT
Bellman Ford's Algorithm
PPTX
Recursion
PPTX
Sorting Algorithms
PPTX
Traveling salesman problem
PPT
Dinive conquer algorithm
PPT
Ll(1) Parser in Compilers
PPT
Branch & bound
PPT
Asymptotic notation
PPTX
Dynamic programming
PPTX
Boyer moore algorithm
PPTX
Asymptotic Notation
PPTX
Job sequencing with deadline
PPT
Minimum spanning tree
PPTX
Data structure tries
PDF
Time and Space Complexity
PPTX
Bruteforce algorithm
PPTX
Huffman coding
Daa notes 1
Master method theorem
Np cooks theorem
Bellman Ford's Algorithm
Recursion
Sorting Algorithms
Traveling salesman problem
Dinive conquer algorithm
Ll(1) Parser in Compilers
Branch & bound
Asymptotic notation
Dynamic programming
Boyer moore algorithm
Asymptotic Notation
Job sequencing with deadline
Minimum spanning tree
Data structure tries
Time and Space Complexity
Bruteforce algorithm
Huffman coding
Ad

Viewers also liked (14)

PDF
Analysis and design of algorithms part 4
PPT
Master method theorem
PDF
Master method
PPT
Divide and conquer
PPT
03 algorithm properties
PPTX
Merge sort analysis and its real time applications
PPT
Algorithm analysis
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
PDF
Quick Sort , Merge Sort , Heap Sort
PPT
Merge sort
PPTX
Design and Analysis of Algorithms
PDF
Master theorem
Analysis and design of algorithms part 4
Master method theorem
Master method
Divide and conquer
03 algorithm properties
Merge sort analysis and its real time applications
Algorithm analysis
DESIGN AND ANALYSIS OF ALGORITHMS
Quick Sort , Merge Sort , Heap Sort
Merge sort
Design and Analysis of Algorithms
Master theorem
Ad

Similar to Master theorem (20)

PPT
Master Theorem Related to The Algorithm Analysis Course
PDF
Recurrence and master theorem
PPT
RecurrenceAndMasterTheorem.ppt
PPTX
master theorem conditions are explained in this
PDF
Master theorm practive problems with solutions
PPTX
AOA.pptx
PPT
Time complexity
PPTX
Improvised Master's Theorem
PPTX
Recurrence relationclass 5
PPTX
solving_recurrence_relations_using_methods.pptx
PDF
Master’s theorem Derivative Analysis
PPTX
solving_Recurrence_relations_using_methods1.pptx
PPTX
UNIT I- Session 8.pptxgdsgdgssdggdsdsgdd
PPTX
Divide and Conquer_Binary_Search_Merge_Sort.pptx
PDF
Computer science-formulas
PPTX
Master's Theorm.pptx
PDF
3.pdf
Master Theorem Related to The Algorithm Analysis Course
Recurrence and master theorem
RecurrenceAndMasterTheorem.ppt
master theorem conditions are explained in this
Master theorm practive problems with solutions
AOA.pptx
Time complexity
Improvised Master's Theorem
Recurrence relationclass 5
solving_recurrence_relations_using_methods.pptx
Master’s theorem Derivative Analysis
solving_Recurrence_relations_using_methods1.pptx
UNIT I- Session 8.pptxgdsgdgssdggdsdsgdd
Divide and Conquer_Binary_Search_Merge_Sort.pptx
Computer science-formulas
Master's Theorm.pptx
3.pdf

More from fika sweety (20)

PPTX
Query optimization and performance
PPT
Program design techniques
PPT
PPT
Shift rotate
PPTX
Graphss
PPT
Modeling and simulation ch 1
PPTX
Macros...presentation
PPT
Pseudocode algorithim flowchart
PPT
Diversity (HRM)
PPT
Howtowriteamemo 090920105907-phpapp02
PPTX
Coal presentationt
PPTX
1 Computer Architecture
PPTX
3 Pipelining
PPT
19 primkruskal
PPT
Warehouse chapter3
PPTX
Storage memory
PPT
Quick sort
PPTX
Query optimization and performance
PPT
Database security copy
PPT
Programming
Query optimization and performance
Program design techniques
Shift rotate
Graphss
Modeling and simulation ch 1
Macros...presentation
Pseudocode algorithim flowchart
Diversity (HRM)
Howtowriteamemo 090920105907-phpapp02
Coal presentationt
1 Computer Architecture
3 Pipelining
19 primkruskal
Warehouse chapter3
Storage memory
Quick sort
Query optimization and performance
Database security copy
Programming

Recently uploaded (20)

PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Project quality management in manufacturing
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
additive manufacturing of ss316l using mig welding
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Construction Project Organization Group 2.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
DOCX
573137875-Attendance-Management-System-original
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Geodesy 1.pptx...............................................
PDF
Digital Logic Computer Design lecture notes
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Project quality management in manufacturing
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
additive manufacturing of ss316l using mig welding
R24 SURVEYING LAB MANUAL for civil enggi
UNIT 4 Total Quality Management .pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Construction Project Organization Group 2.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
573137875-Attendance-Management-System-original
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Geodesy 1.pptx...............................................
Digital Logic Computer Design lecture notes
OOP with Java - Java Introduction (Basics)
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS

Master theorem