SlideShare a Scribd company logo
RECURRENCE
EQUATIONS &
ANALYZING
THEM
By:
ALPANA A. INGALE
ROLL NO. 8108
RECURRENCES
 A recurrence is an equation or inequality that describes a function in
terms of its value on small inputs.
 The running time of the recursive algorithm can be obtained by a
recurrence.
 To solve the recurrence relation mean to obtain a function defined on
the natural numbers that satisfies the recurrence.
2
Recurrence Equation Methods –
cont’d
 We solve the recurrence equation by the following methods. That is:
i. Substitution method
ii. Iterative method
iii. Master method
iv. Recurrence or Recursion Tree
 Substitution Method:
1. In this method, first we guess a solution and use mathematical induction to find
the constant and show that the solution works.
2. The substitution method can be used to establish either upper or lower bounds
on a recurrence.
3
Recurrence Equation Methods –
cont’d
 E.g.: T(n) = 2T(n/2) + n --- (1) is a recurrence relation.
 We guess the solution T(n) = O(nlgn), where g(n) = nlgn is the solution.
 That is: f(n) = T(n) ≤ cnlgn --- (2)
 Then we have to prove that, this solution is true, by using mathematical induction.
 From equation-1, T(n) = 2T(n/2) + n
 T(n) ≤ 2c(n/2) lg(n/2) + n
 T(n) ≤ cn.lg(n/2) + n = cn(lgn – lg2) + n
 T(n) ≤ cnlgn – cn + n.
 So, T(n) ≤ cnlgn – n(c – 1)
 T(n) ≤ cnlgn for c >1
 Now, using mathematical induction, T(n) = T(n-1) + 1.
4
Recurrence Equation Methods –
cont’d
 For n = 1, if T(1) = 1, then c ≥ 1
 lg1 = 0 => T(1) is not true for n = 1.
 For n = 2, if T(2) = 2T(1) + 2 = 4, then c ≥ 4.
 2lg2 => c ≥ 2.
 Hence, T(n) ≤ cnlgn, c > 1 is true
 For n = 2 => T(2) is true.
 Similarly, T(3), T(4) … is true
 T(k) is true.
 T(k + 1) is true by using Tk.
 T(n ) = T(n – 1) + 1, g(n) = n = O(n)
5
Recurrence Equation Methods –
cont’d
 T(n) = T(n – 1) + 1
 T(n) = T(n – 2) + 1 + 1
 T(n) = T(n + 3) + 1 + 1 + 1
 Let k = T(n – k) + k.
 Let n – k = 0 (base value).
 n = k
 T₀ + n = n + 1
 Let T₀ = 1 (base case) T(1) = 1, k = n – 1
 T(n) = 1 + n – 1 = n
 So, it is true for n/2 and it is true for n.
6
Recurrence Equation Methods -
cont’d
 If it is true for n, then it is true for 3.
 If it is true for 3, then it is true for 6 and 7 and if it is true for 6, then it is true for
12 and 13.
 Hence, we conclude that for n ≥ c, where c ≥ 2.
 So, T(n) = O(nlgn) is a solution of T(n) = 2T(n/2) + n.
2. Iterative Method: An iterative method is the method, where the recurrence
relation is solved by considering 3 steps. That is:
1. Step 1: expand the recurrence
2. Step 2: express is as a summation (∑) of terms, dependent only on „n‟ and the initial
condition.
3. Step 3: evaluate the summation (∑).
7
Recurrence Equation Methods –
cont’d
 T(n) = 3T(n/4) + n
 Expanding the above terms, we get
T(n) = 3(3T(n/16)) + (n/4) + n
T(n) = 3(3(3T(n/164))) + (n/16) + (n/4) + n
T(n) = n + 3(n/4) + 9(n/16) + 2T(T(n/164))
 The recursion stops, when n/4ⁱ ≤ 1, which implies n ≤ 4ⁱ => log₄n = i
 Thus, T(n) = n + 3n/4+ … + 3ⁱ(n/4ⁱ)+ 3log₄n.θ(1)
 T(n) ≤ (n + 3n/4 + 9n/16 + … + 3 log₄n)θ(1)
 T(n) ≤ n + θ(n log₄3) {as 3log₄n = n log₄3}
 T(n) ≤ n(1/(1 – ¾)) + O(n)
 T(n) = 4n + O(n) {as log₄3 < 1} = O(n)
 Hence, T(n) = O(n) (proved).
8
k
k


0
)4/3(
Recurrence Equation Methods –
cont’d
3. Master Method: The master method is used for solving the following types of
recurrences, T(n) = aT(n/b) + f(n),
where ‘a’ and ‘b’ are constants and a ≥ 1, b > 1.
 In the above recurrence, the problem of size ‘n’ is divided into ‘a’ sub-
problems each of size ‘n/b’.
 Each sub-problem of size ‘n/b’ can be solved recursively in time T(n/b).
 The cost of dividing or splitting the problem and combine the solutions or
result is described by the function f(n).
 Here the size is interpreted as ‘n/b’.
9
Recurrence Equation Methods –
cont’d
 The T(n) can be bounded asymptotically by the following 3 cases.
10
Recurrence Equation Methods –
cont’d
4. Recursion Tree Method: Recursion Tree Method is pictorial representation of
an iteration method, which is in the form of a tree, where at each levels,
nodes are expanded.
 It is used to keep track of the size of the remaining arguments in the
recurrence and the non-recursive costs.
 In a recursion tree, each node represents the cost of a single sub-problem.
 We add the cost within each level of the tree to obtain a set of pre-level cost
and then we add all the levels of costs to determine the total cost of all levels
of recursion.
 In general, T(n) = aT(n/b) + f(n)
11
Recurrence Equation Methods –
cont’d
12
Recurrence Equation Methods –
cont’d
13
14

More Related Content

What's hot

Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
Rajendran
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
Ajay Chimmani
 
L2
L2L2
Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5
Kumar
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
Rajendran
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Megha V
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3
Traian Rebedea
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
Rajendran
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
lecture 4
lecture 4lecture 4
lecture 4
sajinsc
 
L2
L2L2
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 
02 asymp
02 asymp02 asymp
02 asymp
aparnabk7
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
Sri Prasanna
 
THE BINOMIAL THEOREM
THE BINOMIAL THEOREM THE BINOMIAL THEOREM
THE BINOMIAL THEOREM
τυσηαρ ηαβιβ
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
Anurag Cheela
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
Aqeel Rafique
 
Binomial Theorem
Binomial TheoremBinomial Theorem
Binomial Theorem
itutor
 

What's hot (18)

Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
L2
L2L2
L2
 
Recurrence relationclass 5
Recurrence relationclass 5Recurrence relationclass 5
Recurrence relationclass 5
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
lecture 4
lecture 4lecture 4
lecture 4
 
L2
L2L2
L2
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
02 asymp
02 asymp02 asymp
02 asymp
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
THE BINOMIAL THEOREM
THE BINOMIAL THEOREM THE BINOMIAL THEOREM
THE BINOMIAL THEOREM
 
recurrence relations
 recurrence relations recurrence relations
recurrence relations
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
 
Binomial Theorem
Binomial TheoremBinomial Theorem
Binomial Theorem
 

Similar to RECURRENCE EQUATIONS & ANALYZING THEM

3.pdf
3.pdf3.pdf
3.pdf
AlaaOdeh18
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
B.Kirron Reddi
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
GadaFarhan
 
02 Notes Divide and Conquer
02 Notes Divide and Conquer02 Notes Divide and Conquer
02 Notes Divide and Conquer
Andres Mendez-Vazquez
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equations
Tarun Gehlot
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
Edhole.com
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Vikas Sharma
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
RishikeshJha33
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.ppt
MouDhara1
 
Improvised Master's Theorem
Improvised Master's TheoremImprovised Master's Theorem
Improvised Master's Theorem
Laiba Younas
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
Waqas Akram
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
jayavignesh86
 
2.pptx
2.pptx2.pptx
2.pptx
MohAlyasin1
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
Nehagupta259541
 
published research papers
published research paperspublished research papers
published research papers
graphicdesigner79
 
journal of mathematics research
journal of mathematics researchjournal of mathematics research
journal of mathematics research
rikaseorika
 
research paper publication journals
research paper publication journalsresearch paper publication journals
research paper publication journals
rikaseorika
 
03 dc
03 dc03 dc
03 dc
Hira Gul
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
Krish_ver2
 

Similar to RECURRENCE EQUATIONS & ANALYZING THEM (20)

3.pdf
3.pdf3.pdf
3.pdf
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
02 Notes Divide and Conquer
02 Notes Divide and Conquer02 Notes Divide and Conquer
02 Notes Divide and Conquer
 
Recurrence equations
Recurrence equationsRecurrence equations
Recurrence equations
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.ppt
 
Improvised Master's Theorem
Improvised Master's TheoremImprovised Master's Theorem
Improvised Master's Theorem
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
 
2.pptx
2.pptx2.pptx
2.pptx
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
published research papers
published research paperspublished research papers
published research papers
 
journal of mathematics research
journal of mathematics researchjournal of mathematics research
journal of mathematics research
 
research paper publication journals
research paper publication journalsresearch paper publication journals
research paper publication journals
 
03 dc
03 dc03 dc
03 dc
 
5.2 divide and conquer
5.2 divide and conquer5.2 divide and conquer
5.2 divide and conquer
 

More from Alpana Ingale

ECG BIOMETRICS
ECG BIOMETRICSECG BIOMETRICS
ECG BIOMETRICS
Alpana Ingale
 
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENTWaste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
Alpana Ingale
 
FCC REGULATIONS
FCC REGULATIONSFCC REGULATIONS
FCC REGULATIONS
Alpana Ingale
 
TELEMETRY, TRACKING COMMAND & MONITORING
TELEMETRY, TRACKING COMMAND & MONITORINGTELEMETRY, TRACKING COMMAND & MONITORING
TELEMETRY, TRACKING COMMAND & MONITORING
Alpana Ingale
 
SPECTRUM SENSING PROCEDURE & SENSING TREE
SPECTRUM SENSING PROCEDURE & SENSING TREESPECTRUM SENSING PROCEDURE & SENSING TREE
SPECTRUM SENSING PROCEDURE & SENSING TREE
Alpana Ingale
 
QAM
QAMQAM
ANIMATRONICS
ANIMATRONICSANIMATRONICS
ANIMATRONICS
Alpana Ingale
 

More from Alpana Ingale (7)

ECG BIOMETRICS
ECG BIOMETRICSECG BIOMETRICS
ECG BIOMETRICS
 
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENTWaste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
 
FCC REGULATIONS
FCC REGULATIONSFCC REGULATIONS
FCC REGULATIONS
 
TELEMETRY, TRACKING COMMAND & MONITORING
TELEMETRY, TRACKING COMMAND & MONITORINGTELEMETRY, TRACKING COMMAND & MONITORING
TELEMETRY, TRACKING COMMAND & MONITORING
 
SPECTRUM SENSING PROCEDURE & SENSING TREE
SPECTRUM SENSING PROCEDURE & SENSING TREESPECTRUM SENSING PROCEDURE & SENSING TREE
SPECTRUM SENSING PROCEDURE & SENSING TREE
 
QAM
QAMQAM
QAM
 
ANIMATRONICS
ANIMATRONICSANIMATRONICS
ANIMATRONICS
 

Recently uploaded

SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
ecqow
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
OKORIE1
 
5G Radio Network Througput Problem Analysis HCIA.pdf
5G Radio Network Througput Problem Analysis HCIA.pdf5G Radio Network Througput Problem Analysis HCIA.pdf
5G Radio Network Througput Problem Analysis HCIA.pdf
AlvianRamadhani5
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
upoux
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
Kamal Acharya
 
openshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoinopenshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoin
snaprevwdev
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...
DharmaBanothu
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
CE19KaushlendraKumar
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
Kamal Acharya
 
Unit -II Spectroscopy - EC I B.Tech.pdf
Unit -II Spectroscopy - EC  I B.Tech.pdfUnit -II Spectroscopy - EC  I B.Tech.pdf
Unit -II Spectroscopy - EC I B.Tech.pdf
TeluguBadi
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
b0754201
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
sydezfe
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
ijseajournal
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 

Recently uploaded (20)

SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
一比一原版(CalArts毕业证)加利福尼亚艺术学院毕业证如何办理
 
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
DESIGN AND MANUFACTURE OF CEILING BOARD USING SAWDUST AND WASTE CARTON MATERI...
 
5G Radio Network Througput Problem Analysis HCIA.pdf
5G Radio Network Througput Problem Analysis HCIA.pdf5G Radio Network Througput Problem Analysis HCIA.pdf
5G Radio Network Througput Problem Analysis HCIA.pdf
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
Supermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdfSupermarket Management System Project Report.pdf
Supermarket Management System Project Report.pdf
 
openshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoinopenshift technical overview - Flow of openshift containerisatoin
openshift technical overview - Flow of openshift containerisatoin
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...This study Examines the Effectiveness of Talent Procurement through the Imple...
This study Examines the Effectiveness of Talent Procurement through the Imple...
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
 
Unit -II Spectroscopy - EC I B.Tech.pdf
Unit -II Spectroscopy - EC  I B.Tech.pdfUnit -II Spectroscopy - EC  I B.Tech.pdf
Unit -II Spectroscopy - EC I B.Tech.pdf
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
 
Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...Call For Paper -3rd International Conference on Artificial Intelligence Advan...
Call For Paper -3rd International Conference on Artificial Intelligence Advan...
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 

RECURRENCE EQUATIONS & ANALYZING THEM

  • 2. RECURRENCES  A recurrence is an equation or inequality that describes a function in terms of its value on small inputs.  The running time of the recursive algorithm can be obtained by a recurrence.  To solve the recurrence relation mean to obtain a function defined on the natural numbers that satisfies the recurrence. 2
  • 3. Recurrence Equation Methods – cont’d  We solve the recurrence equation by the following methods. That is: i. Substitution method ii. Iterative method iii. Master method iv. Recurrence or Recursion Tree  Substitution Method: 1. In this method, first we guess a solution and use mathematical induction to find the constant and show that the solution works. 2. The substitution method can be used to establish either upper or lower bounds on a recurrence. 3
  • 4. Recurrence Equation Methods – cont’d  E.g.: T(n) = 2T(n/2) + n --- (1) is a recurrence relation.  We guess the solution T(n) = O(nlgn), where g(n) = nlgn is the solution.  That is: f(n) = T(n) ≤ cnlgn --- (2)  Then we have to prove that, this solution is true, by using mathematical induction.  From equation-1, T(n) = 2T(n/2) + n  T(n) ≤ 2c(n/2) lg(n/2) + n  T(n) ≤ cn.lg(n/2) + n = cn(lgn – lg2) + n  T(n) ≤ cnlgn – cn + n.  So, T(n) ≤ cnlgn – n(c – 1)  T(n) ≤ cnlgn for c >1  Now, using mathematical induction, T(n) = T(n-1) + 1. 4
  • 5. Recurrence Equation Methods – cont’d  For n = 1, if T(1) = 1, then c ≥ 1  lg1 = 0 => T(1) is not true for n = 1.  For n = 2, if T(2) = 2T(1) + 2 = 4, then c ≥ 4.  2lg2 => c ≥ 2.  Hence, T(n) ≤ cnlgn, c > 1 is true  For n = 2 => T(2) is true.  Similarly, T(3), T(4) … is true  T(k) is true.  T(k + 1) is true by using Tk.  T(n ) = T(n – 1) + 1, g(n) = n = O(n) 5
  • 6. Recurrence Equation Methods – cont’d  T(n) = T(n – 1) + 1  T(n) = T(n – 2) + 1 + 1  T(n) = T(n + 3) + 1 + 1 + 1  Let k = T(n – k) + k.  Let n – k = 0 (base value).  n = k  T₀ + n = n + 1  Let T₀ = 1 (base case) T(1) = 1, k = n – 1  T(n) = 1 + n – 1 = n  So, it is true for n/2 and it is true for n. 6
  • 7. Recurrence Equation Methods - cont’d  If it is true for n, then it is true for 3.  If it is true for 3, then it is true for 6 and 7 and if it is true for 6, then it is true for 12 and 13.  Hence, we conclude that for n ≥ c, where c ≥ 2.  So, T(n) = O(nlgn) is a solution of T(n) = 2T(n/2) + n. 2. Iterative Method: An iterative method is the method, where the recurrence relation is solved by considering 3 steps. That is: 1. Step 1: expand the recurrence 2. Step 2: express is as a summation (∑) of terms, dependent only on „n‟ and the initial condition. 3. Step 3: evaluate the summation (∑). 7
  • 8. Recurrence Equation Methods – cont’d  T(n) = 3T(n/4) + n  Expanding the above terms, we get T(n) = 3(3T(n/16)) + (n/4) + n T(n) = 3(3(3T(n/164))) + (n/16) + (n/4) + n T(n) = n + 3(n/4) + 9(n/16) + 2T(T(n/164))  The recursion stops, when n/4ⁱ ≤ 1, which implies n ≤ 4ⁱ => log₄n = i  Thus, T(n) = n + 3n/4+ … + 3ⁱ(n/4ⁱ)+ 3log₄n.θ(1)  T(n) ≤ (n + 3n/4 + 9n/16 + … + 3 log₄n)θ(1)  T(n) ≤ n + θ(n log₄3) {as 3log₄n = n log₄3}  T(n) ≤ n(1/(1 – ¾)) + O(n)  T(n) = 4n + O(n) {as log₄3 < 1} = O(n)  Hence, T(n) = O(n) (proved). 8 k k   0 )4/3(
  • 9. Recurrence Equation Methods – cont’d 3. Master Method: The master method is used for solving the following types of recurrences, T(n) = aT(n/b) + f(n), where ‘a’ and ‘b’ are constants and a ≥ 1, b > 1.  In the above recurrence, the problem of size ‘n’ is divided into ‘a’ sub- problems each of size ‘n/b’.  Each sub-problem of size ‘n/b’ can be solved recursively in time T(n/b).  The cost of dividing or splitting the problem and combine the solutions or result is described by the function f(n).  Here the size is interpreted as ‘n/b’. 9
  • 10. Recurrence Equation Methods – cont’d  The T(n) can be bounded asymptotically by the following 3 cases. 10
  • 11. Recurrence Equation Methods – cont’d 4. Recursion Tree Method: Recursion Tree Method is pictorial representation of an iteration method, which is in the form of a tree, where at each levels, nodes are expanded.  It is used to keep track of the size of the remaining arguments in the recurrence and the non-recursive costs.  In a recursion tree, each node represents the cost of a single sub-problem.  We add the cost within each level of the tree to obtain a set of pre-level cost and then we add all the levels of costs to determine the total cost of all levels of recursion.  In general, T(n) = aT(n/b) + f(n) 11
  • 12. Recurrence Equation Methods – cont’d 12
  • 13. Recurrence Equation Methods – cont’d 13
  • 14. 14