SlideShare a Scribd company logo
1 of 7
Recurrences
• The expression:
is a recurrence.
– Recurrence: an equation that describes a function in
terms of its value on smaller functions

















1
2
2
1
)
(
n
cn
n
T
n
c
n
T
2
Master Method/Theorem
• Theorem 4.1 (page 73)
– for T(n) = aT(n/b)+f(n), n/b may be n/b or n/b.
– where a  1, b>1 are positive integers, f(n) be a non-
negative function.
1. If f(n)=O(nlogb
a-) for some >0, then T(n)= (nlogb
a
).
2. If f(n)= (nlogb
a
), then T(n)= (nlogb
a
lg n).
3. If f(n)=(nlogb
a+) for some >0, and if af(n/b) cf(n)
for some c<1 and all sufficiently large n, then T(n)=
(f(n)).
3
Implications of Master Theorem
• Comparison between f(n) and nlogb
a
(<,=,>)
• Must be asymptotically smaller (or larger) by a
polynomial, i.e., n
for some >0.
• In case 3, the “regularity” must be satisfied, i.e.,
af(n/b) cf(n) for some c<1 .
• There are gaps
– between 1 and 2: f(n) is smaller than nlogb
a
, but not
polynomially smaller.
– between 2 and 3: f(n) is larger than nlogb
a
, but not
polynomially larger.
– in case 3, if the “regularity” fails to hold.
4
Application of Master Theorem
• T(n) = 9T(n/3)+n;
– a=9,b=3, f(n) =n
– nlogb
a
= nlog3
9
=  (n2)
– f(n)=O(nlog3
9-) for =1
– By case 1, T(n) = (n2).
• T(n) = T(2n/3)+1
– a=1,b=3/2, f(n) =1
– nlogb
a
= nlog3/2
1
=  (n0) =  (1)
– By case 2, T(n)= (lg n).
5
Application of Master Theorem
• T(n) = 3T(n/4)+nlg n;
– a=3,b=4, f(n) =nlg n
– nlogb
a
= nlog4
3
=  (n0.793)
– f(n)= (nlog4
3+) for 0.2
– Moreover, for large n, the “regularity” holds for
c=3/4.
• af(n/b) =3(n/4)lg (n/4)  (3/4)nlg n = cf(n)
– By case 3, T(n) = (f(n))= (nlg n).
6
Exception to Master Theorem
• T(n) = 2T(n/2)+nlg n;
– a=2,b=2, f(n) =nlg n
– nlogb
a
= nlog2
2
=  (n)
– f(n) is asymptotically larger than nlogb
a
, but not
polynomially larger because
– f(n)/nlogb
a
= lg n, which is asymptotically less
than n for any >0.
– Therefore,this is a gap between 2 and 3.
7
Where Are the Gaps
nlogba f(n), case 2: within constant distances
c1
c2
n
f(n), case 1, at least polynomially smaller
Gap between case 1 and 2
n Gap between case 3 and 2
f(n), case 3, at least polynomially larger
Note: 1. for case 3, the regularity also must hold.
2. if f(n) is lg n smaller, then fall in gap in 1 and 2
3. if f(n) is lg n larger, then fall in gap in 3 and 2
4. if f(n)=(nlogba
lgk
n), then T(n)=(nlogba
lgk+1
n). (as exercise)

More Related Content

Similar to RecurrenceAndMasterTheorem.ppt

Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5Kumar
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutionssubhashchandra197
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategyNisha Soms
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquerVikas Sharma
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxGadaFarhan
 
Recurrences
RecurrencesRecurrences
RecurrencesDEVTYPE
 
Master theorm practive problems with solutions
Master theorm practive problems with solutionsMaster theorm practive problems with solutions
Master theorm practive problems with solutionsKumar
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptZohairMughal1
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptZohairMughal1
 
lecture 3
lecture 3lecture 3
lecture 3sajinsc
 
Lecture 3 complexity
Lecture 3 complexityLecture 3 complexity
Lecture 3 complexityMadhu Niket
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..KarthikeyaLanka1
 

Similar to RecurrenceAndMasterTheorem.ppt (20)

Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5
 
3.pdf
3.pdf3.pdf
3.pdf
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
Divide and conquer strategy
Divide and conquer strategyDivide and conquer strategy
Divide and conquer strategy
 
Master
MasterMaster
Master
 
Master method
Master methodMaster method
Master method
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Master theorm practive problems with solutions
Master theorm practive problems with solutionsMaster theorm practive problems with solutions
Master theorm practive problems with solutions
 
calculus-4c-1.pdf
calculus-4c-1.pdfcalculus-4c-1.pdf
calculus-4c-1.pdf
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Lecture3(b).pdf
Lecture3(b).pdfLecture3(b).pdf
Lecture3(b).pdf
 
L2
L2L2
L2
 
Lecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).pptLecture 4 - Growth of Functions (1).ppt
Lecture 4 - Growth of Functions (1).ppt
 
Lecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.pptLecture 4 - Growth of Functions.ppt
Lecture 4 - Growth of Functions.ppt
 
lecture 3
lecture 3lecture 3
lecture 3
 
Lecture 3 complexity
Lecture 3 complexityLecture 3 complexity
Lecture 3 complexity
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

RecurrenceAndMasterTheorem.ppt

  • 1. Recurrences • The expression: is a recurrence. – Recurrence: an equation that describes a function in terms of its value on smaller functions                  1 2 2 1 ) ( n cn n T n c n T
  • 2. 2 Master Method/Theorem • Theorem 4.1 (page 73) – for T(n) = aT(n/b)+f(n), n/b may be n/b or n/b. – where a  1, b>1 are positive integers, f(n) be a non- negative function. 1. If f(n)=O(nlogb a-) for some >0, then T(n)= (nlogb a ). 2. If f(n)= (nlogb a ), then T(n)= (nlogb a lg n). 3. If f(n)=(nlogb a+) for some >0, and if af(n/b) cf(n) for some c<1 and all sufficiently large n, then T(n)= (f(n)).
  • 3. 3 Implications of Master Theorem • Comparison between f(n) and nlogb a (<,=,>) • Must be asymptotically smaller (or larger) by a polynomial, i.e., n for some >0. • In case 3, the “regularity” must be satisfied, i.e., af(n/b) cf(n) for some c<1 . • There are gaps – between 1 and 2: f(n) is smaller than nlogb a , but not polynomially smaller. – between 2 and 3: f(n) is larger than nlogb a , but not polynomially larger. – in case 3, if the “regularity” fails to hold.
  • 4. 4 Application of Master Theorem • T(n) = 9T(n/3)+n; – a=9,b=3, f(n) =n – nlogb a = nlog3 9 =  (n2) – f(n)=O(nlog3 9-) for =1 – By case 1, T(n) = (n2). • T(n) = T(2n/3)+1 – a=1,b=3/2, f(n) =1 – nlogb a = nlog3/2 1 =  (n0) =  (1) – By case 2, T(n)= (lg n).
  • 5. 5 Application of Master Theorem • T(n) = 3T(n/4)+nlg n; – a=3,b=4, f(n) =nlg n – nlogb a = nlog4 3 =  (n0.793) – f(n)= (nlog4 3+) for 0.2 – Moreover, for large n, the “regularity” holds for c=3/4. • af(n/b) =3(n/4)lg (n/4)  (3/4)nlg n = cf(n) – By case 3, T(n) = (f(n))= (nlg n).
  • 6. 6 Exception to Master Theorem • T(n) = 2T(n/2)+nlg n; – a=2,b=2, f(n) =nlg n – nlogb a = nlog2 2 =  (n) – f(n) is asymptotically larger than nlogb a , but not polynomially larger because – f(n)/nlogb a = lg n, which is asymptotically less than n for any >0. – Therefore,this is a gap between 2 and 3.
  • 7. 7 Where Are the Gaps nlogba f(n), case 2: within constant distances c1 c2 n f(n), case 1, at least polynomially smaller Gap between case 1 and 2 n Gap between case 3 and 2 f(n), case 3, at least polynomially larger Note: 1. for case 3, the regularity also must hold. 2. if f(n) is lg n smaller, then fall in gap in 1 and 2 3. if f(n) is lg n larger, then fall in gap in 3 and 2 4. if f(n)=(nlogba lgk n), then T(n)=(nlogba lgk+1 n). (as exercise)