SlideShare a Scribd company logo
1 of 25
Download to read offline
UNIT-1
3RD YEAR (5TH SEM)
(2020-21)
Design and Analysis of
Algorithm (KCS503)
Submitted By:
Jeetesh Srivastava
Asst. Prof.(CSE)
UCEM, Prayagraj
2
Extended Master
Method
Mr. Jeetesh Srivastava (DAA(KCS503))
Extended Master Method
Here, a >= 1, b > 1, k >= 0 and p is a real number.
 To solve recurrence relations using Master’s
theorem, we compare a with bk.
 Then, we follow the following cases-
3
Mr. Jeetesh Srivastava (DAA(KCS503))
Extended Master Method (cont)
Case-01:
 If a > bk, then T(n) = θ (nlog
b
a)
Case-02:
 If a = bk and
If p < -1, then T(n) = θ (nlog
b
a)
If p = -1, then T(n) = θ (nlog
b
a.log2n)
If p > -1, then T(n) = θ (nlog
b
a.logp+1n)
Case-03:
If a < bk and
 If p < 0, then T(n) = O (nk)
 If p >= 0, then T(n) = θ (nklogpn)
4
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-1
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = 2T(n/2) + nlogn
 Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
 Then, we have- a = 2, b = 2, k = 1, p = 1
 Now, a = 2 and bk = 21 = 2.
 Clearly, a = bk.
 So From Case 2, Since p = 1, so we have-
 T(n) = θ (nlog
b
a.logp+1n)
 T(n) = θ (nlog
2
2.log1+1n)
5
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-1
Mr. Jeetesh Srivastava (DAA(KCS503))
6
 Thus T(n) = θ (nlog2n)
Example-2
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = 2T(n/4) + n0.51
 Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
 Then, we have- a = 2, b = 4, k = 0.51, p = 0
 Now, a = 2 and bk = 40.51 = 2.0279.
 Clearly, a < bk.
 So From Case 3, Since p = 0, so we have-
 T(n) = θ (nklogpn)
 T(n) = θ (n0.51log0n)
7
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-2
Mr. Jeetesh Srivastava (DAA(KCS503))
8
 Thus T(n) = θ (n0.51)
Example-3
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = √2T(n/2) + logn
 Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
 Then, we have- a = √2, b = 2, k = 0, p = 1
 Now, a = √2 = 1.414 and bk = 20 = 1.
 Clearly, a > bk.
 So From Case 1,
 T(n) = θ (nlog
b
a) = θ (nlog
2
√2)
 T(n) = θ (n1/2)
9
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-3
Mr. Jeetesh Srivastava (DAA(KCS503))
10
 Thus T(n) = θ (√n)
Example-4
Ex: T (n) = 0.5T (n/2) + 1/n
11
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-4
 Solution:
T (n) = 0.5T (n/2) + 1/n ⇒ Does not apply (a < 1)
12
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-5
Ex: T (n) = 2nT (n/2) + nn
13
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-5
 Solution:
T (n) = 2nT (n/2) + nn ⇒ Does not apply (a is not
constant)
14
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-6
T (n) = 64T (n/8)− n2 log n
15
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-6
 Solution:
T (n) = 64T (n/8)− n2 log n ⇒ Does not apply (f(n) is
not positive)
16
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-7
T (n) = 3T (n/3) + √ n
17
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-7
 Solution:
T (n) = 3T (n/3) + √ n ⇒ T (n) = Θ(n) (Case 1)
18
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-8
T (n) = √ 2T (n/2) + log n
19
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-8
 Solution:
T (n) = √ 2T (n/2) + log n ⇒ T (n) = Θ(√ n) (Case 1)
20
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-9
T (n) = 4T (n/2) + n/ log n
21
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-9
 Solution:
T (n) = 4T (n/2) + n/ log n ⇒ T (n) = Θ(n2 ) (Case
1)
22
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-10
T (n) = 3T (n/3) + n/2
23
Mr. Jeetesh Srivastava (DAA(KCS503))
Example-10
 Solution:
T (n) = 3T (n/3) + n/2 ⇒ T (n) = Θ(n log n) (Case 2)
24
Mr. Jeetesh Srivastava (DAA(KCS503))
25
Thank You
Mr. Jeetesh Srivastava (DAA(KCS503))

More Related Content

What's hot

What's hot (20)

Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
First order logic
First order logicFirst order logic
First order logic
 
Row Space,Column Space and Null Space & Rank and Nullity
Row Space,Column Space and Null Space & Rank and NullityRow Space,Column Space and Null Space & Rank and Nullity
Row Space,Column Space and Null Space & Rank and Nullity
 
8085 Microprocessor
8085 Microprocessor8085 Microprocessor
8085 Microprocessor
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Crisp set
Crisp setCrisp set
Crisp set
 
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDAPush Down Automata (PDA) | TOC  (Theory of Computation) | NPDA | DPDA
Push Down Automata (PDA) | TOC (Theory of Computation) | NPDA | DPDA
 
Euler and runge kutta method
Euler and runge kutta methodEuler and runge kutta method
Euler and runge kutta method
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Avl tree
Avl treeAvl tree
Avl tree
 
Forms of learning in ai
Forms of learning in aiForms of learning in ai
Forms of learning in ai
 
Frames
FramesFrames
Frames
 
1.9. minimization of dfa
1.9. minimization of dfa1.9. minimization of dfa
1.9. minimization of dfa
 
Root locus method
Root locus methodRoot locus method
Root locus method
 
Error(Computer Oriented Numerical and Statistical Method)
Error(Computer Oriented Numerical and Statistical Method)Error(Computer Oriented Numerical and Statistical Method)
Error(Computer Oriented Numerical and Statistical Method)
 
Interpolation
InterpolationInterpolation
Interpolation
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
Data Structure: Algorithm and analysis
Data Structure: Algorithm and analysisData Structure: Algorithm and analysis
Data Structure: Algorithm and analysis
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 

Similar to Lecture no 9(extended master method)

lecture 3
lecture 3lecture 3
lecture 3
sajinsc
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
GadaFarhan
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
Sri Prasanna
 

Similar to Lecture no 9(extended master method) (20)

Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
Recurrences
RecurrencesRecurrences
Recurrences
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.ppt
 
lecture 3
lecture 3lecture 3
lecture 3
 
LINEAR SYSTEMS
LINEAR SYSTEMSLINEAR SYSTEMS
LINEAR SYSTEMS
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715Fundamentals of Transport Phenomena ChE 715
Fundamentals of Transport Phenomena ChE 715
 
Signals and systems: part i solutions
Signals and systems: part i solutionsSignals and systems: part i solutions
Signals and systems: part i solutions
 
recurence solutions
recurence solutionsrecurence solutions
recurence solutions
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
Sample question paper 2 with solution
Sample question paper 2 with solutionSample question paper 2 with solution
Sample question paper 2 with solution
 
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
3.-SEQUENCES-AND-SERIES-THEORY.hhsssspdf
 
Master
MasterMaster
Master
 
Master method
Master methodMaster method
Master method
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
Diagram Venn Beserta Contoh Soal
Diagram Venn Beserta Contoh SoalDiagram Venn Beserta Contoh Soal
Diagram Venn Beserta Contoh Soal
 
Variants of the Christ-Kiselev lemma and an application to the maximal Fourie...
Variants of the Christ-Kiselev lemma and an application to the maximal Fourie...Variants of the Christ-Kiselev lemma and an application to the maximal Fourie...
Variants of the Christ-Kiselev lemma and an application to the maximal Fourie...
 
11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series
 
Scattering theory analogues of several classical estimates in Fourier analysis
Scattering theory analogues of several classical estimates in Fourier analysisScattering theory analogues of several classical estimates in Fourier analysis
Scattering theory analogues of several classical estimates in Fourier analysis
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 

Lecture no 9(extended master method)

  • 1. UNIT-1 3RD YEAR (5TH SEM) (2020-21) Design and Analysis of Algorithm (KCS503) Submitted By: Jeetesh Srivastava Asst. Prof.(CSE) UCEM, Prayagraj
  • 2. 2 Extended Master Method Mr. Jeetesh Srivastava (DAA(KCS503))
  • 3. Extended Master Method Here, a >= 1, b > 1, k >= 0 and p is a real number.  To solve recurrence relations using Master’s theorem, we compare a with bk.  Then, we follow the following cases- 3 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 4. Extended Master Method (cont) Case-01:  If a > bk, then T(n) = θ (nlog b a) Case-02:  If a = bk and If p < -1, then T(n) = θ (nlog b a) If p = -1, then T(n) = θ (nlog b a.log2n) If p > -1, then T(n) = θ (nlog b a.logp+1n) Case-03: If a < bk and  If p < 0, then T(n) = O (nk)  If p >= 0, then T(n) = θ (nklogpn) 4 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 5. Example-1 Ex: Solve the following recurrence relation using Master’s theorem- T(n) = 2T(n/2) + nlogn  Solution: We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn).  Then, we have- a = 2, b = 2, k = 1, p = 1  Now, a = 2 and bk = 21 = 2.  Clearly, a = bk.  So From Case 2, Since p = 1, so we have-  T(n) = θ (nlog b a.logp+1n)  T(n) = θ (nlog 2 2.log1+1n) 5 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 6. Example-1 Mr. Jeetesh Srivastava (DAA(KCS503)) 6  Thus T(n) = θ (nlog2n)
  • 7. Example-2 Ex: Solve the following recurrence relation using Master’s theorem- T(n) = 2T(n/4) + n0.51  Solution: We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn).  Then, we have- a = 2, b = 4, k = 0.51, p = 0  Now, a = 2 and bk = 40.51 = 2.0279.  Clearly, a < bk.  So From Case 3, Since p = 0, so we have-  T(n) = θ (nklogpn)  T(n) = θ (n0.51log0n) 7 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 8. Example-2 Mr. Jeetesh Srivastava (DAA(KCS503)) 8  Thus T(n) = θ (n0.51)
  • 9. Example-3 Ex: Solve the following recurrence relation using Master’s theorem- T(n) = √2T(n/2) + logn  Solution: We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn).  Then, we have- a = √2, b = 2, k = 0, p = 1  Now, a = √2 = 1.414 and bk = 20 = 1.  Clearly, a > bk.  So From Case 1,  T(n) = θ (nlog b a) = θ (nlog 2 √2)  T(n) = θ (n1/2) 9 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 10. Example-3 Mr. Jeetesh Srivastava (DAA(KCS503)) 10  Thus T(n) = θ (√n)
  • 11. Example-4 Ex: T (n) = 0.5T (n/2) + 1/n 11 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 12. Example-4  Solution: T (n) = 0.5T (n/2) + 1/n ⇒ Does not apply (a < 1) 12 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 13. Example-5 Ex: T (n) = 2nT (n/2) + nn 13 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 14. Example-5  Solution: T (n) = 2nT (n/2) + nn ⇒ Does not apply (a is not constant) 14 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 15. Example-6 T (n) = 64T (n/8)− n2 log n 15 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 16. Example-6  Solution: T (n) = 64T (n/8)− n2 log n ⇒ Does not apply (f(n) is not positive) 16 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 17. Example-7 T (n) = 3T (n/3) + √ n 17 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 18. Example-7  Solution: T (n) = 3T (n/3) + √ n ⇒ T (n) = Θ(n) (Case 1) 18 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 19. Example-8 T (n) = √ 2T (n/2) + log n 19 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 20. Example-8  Solution: T (n) = √ 2T (n/2) + log n ⇒ T (n) = Θ(√ n) (Case 1) 20 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 21. Example-9 T (n) = 4T (n/2) + n/ log n 21 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 22. Example-9  Solution: T (n) = 4T (n/2) + n/ log n ⇒ T (n) = Θ(n2 ) (Case 1) 22 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 23. Example-10 T (n) = 3T (n/3) + n/2 23 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 24. Example-10  Solution: T (n) = 3T (n/3) + n/2 ⇒ T (n) = Θ(n log n) (Case 2) 24 Mr. Jeetesh Srivastava (DAA(KCS503))
  • 25. 25 Thank You Mr. Jeetesh Srivastava (DAA(KCS503))