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

PPT
Recurrences
PDF
PDF
Master theorem
PPT
Recursion tree method
PDF
Master method
PPT
Master method
PPT
Time complexity
PDF
Recurrences
Recurrences
Master theorem
Recursion tree method
Master method
Master method
Time complexity
Recurrences

What's hot (18)

PPT
Recurrence theorem
PDF
Recurrence relation
PPTX
Recurrence relationclass 5
PPT
Master method theorem
PPTX
Solving recurrences
PPTX
Algorithm Design and Complexity - Course 3
PPT
Proof master theorem
PPT
5.2 divede and conquer 03
PPT
lecture 4
PPT
Dinive conquer algorithm
PPT
02 asymp
PPT
Analysis Of Algorithms Ii
PPT
THE BINOMIAL THEOREM
PPTX
recurrence relations
PPTX
Binomial Theorem, Recursion ,Tower of Honai, relations
PPTX
Binomial Theorem
Recurrence theorem
Recurrence relation
Recurrence relationclass 5
Master method theorem
Solving recurrences
Algorithm Design and Complexity - Course 3
Proof master theorem
5.2 divede and conquer 03
lecture 4
Dinive conquer algorithm
02 asymp
Analysis Of Algorithms Ii
THE BINOMIAL THEOREM
recurrence relations
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem
Ad

Similar to RECURRENCE EQUATIONS & ANALYZING THEM (20)

PPT
recurrence relation is explained in this
PDF
3.pdf
PPTX
PCC_CS_404_OUCHITYAPRODHAN_17000124029[1].pptx
PPT
recurrence relations in analysis of algorithm
PDF
Daa chapter 2
PPTX
T2311 - Ch 4_Part1.pptx
PDF
02 Notes Divide and Conquer
PPT
3. Recursion and Recurrences.ppt detail about recursive learning
DOCX
Recurrence equations
PPT
Admission in india 2015
PDF
6_12_13Asymptotic analysiskfnhlkjsbfbkjs.pdf
PPT
Divide and conquer
PDF
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
PPT
04_Recurrences_1.ppt
PPTX
Improvised Master's Theorem
PDF
Solving recurrences
PDF
Solving recurrences
PDF
Lecture 5 6_7 - divide and conquer and method of solving recurrences
PPTX
2.pptx
PPT
algo_vc_lecture8.ppt
recurrence relation is explained in this
3.pdf
PCC_CS_404_OUCHITYAPRODHAN_17000124029[1].pptx
recurrence relations in analysis of algorithm
Daa chapter 2
T2311 - Ch 4_Part1.pptx
02 Notes Divide and Conquer
3. Recursion and Recurrences.ppt detail about recursive learning
Recurrence equations
Admission in india 2015
6_12_13Asymptotic analysiskfnhlkjsbfbkjs.pdf
Divide and conquer
8.-DAA-LECTURE-8-RECURRENCES-AND-ITERATION-METHOD.pdf
04_Recurrences_1.ppt
Improvised Master's Theorem
Solving recurrences
Solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
2.pptx
algo_vc_lecture8.ppt
Ad

More from Alpana Ingale (7)

PPTX
ECG BIOMETRICS
PPTX
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
PPTX
FCC REGULATIONS
PPTX
TELEMETRY, TRACKING COMMAND & MONITORING
PPTX
SPECTRUM SENSING PROCEDURE & SENSING TREE
PPTX
ANIMATRONICS
ECG BIOMETRICS
Waste Management, Disease Control, ROLES & RESPONSIBILITIES OF GOVERNMENT
FCC REGULATIONS
TELEMETRY, TRACKING COMMAND & MONITORING
SPECTRUM SENSING PROCEDURE & SENSING TREE
ANIMATRONICS

Recently uploaded (20)

PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Sustainable Sites - Green Building Construction
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
PPT on Performance Review to get promotions
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPT
Mechanical Engineering MATERIALS Selection
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Digital Logic Computer Design lecture notes
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Sustainable Sites - Green Building Construction
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Foundation to blockchain - A guide to Blockchain Tech
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
CH1 Production IntroductoryConcepts.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT on Performance Review to get promotions
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Internet of Things (IOT) - A guide to understanding
bas. eng. economics group 4 presentation 1.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mechanical Engineering MATERIALS Selection
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Digital Logic Computer Design lecture notes

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