SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
Master Theorem:
Practice Problems and Solutions

Master Theorem
The Master Theorem applies to recurrences of the following form:
T (n) = aT (n/b) + f (n)
where a ≥ 1 and b > 1 are constants and f (n) is an asymptotically positive function.
There are 3 cases:
1. If f (n) = O(nlogb a− ) for some constant

> 0, then T (n) = Θ(nlogb a ).

2. If f (n) = Θ(nlogb a logk n) with1 k ≥ 0, then T (n) = Θ(nlogb a logk+1 n).
3. If f (n) = Ω(nlogb a+ ) with > 0, and f (n) satisfies the regularity condition, then T (n) = Θ(f (n)).
Regularity condition: af (n/b) ≤ cf (n) for some constant c < 1 and all sufficiently large n.

Practice Problems
For each of the following recurrences, give an expression for the runtime T (n) if the recurrence can be
solved with the Master Theorem. Otherwise, indicate that the Master Theorem does not apply.
1. T (n) = 3T (n/2) + n2

2. T (n) = 4T (n/2) + n2

3. T (n) = T (n/2) + 2n

4. T (n) = 2n T (n/2) + nn

5. T (n) = 16T (n/4) + n

6. T (n) = 2T (n/2) + n log n

1 most

of the time, k = 0

1
7. T (n) = 2T (n/2) + n/ log n

8. T (n) = 2T (n/4) + n0.51

9. T (n) = 0.5T (n/2) + 1/n

10. T (n) = 16T (n/4) + n!

11. T (n) =

√
2T (n/2) + log n

12. T (n) = 3T (n/2) + n

13. T (n) = 3T (n/3) +

√
n

14. T (n) = 4T (n/2) + cn

15. T (n) = 3T (n/4) + n log n

16. T (n) = 3T (n/3) + n/2

17. T (n) = 6T (n/3) + n2 log n

18. T (n) = 4T (n/2) + n/ log n

19. T (n) = 64T (n/8) − n2 log n
20. T (n) = 7T (n/3) + n2

21. T (n) = 4T (n/2) + log n

22. T (n) = T (n/2) + n(2 − cos n)

2
Solutions
1. T (n) = 3T (n/2) + n2 =⇒ T (n) = Θ(n2 ) (Case 3)
2. T (n) = 4T (n/2) + n2 =⇒ T (n) = Θ(n2 log n) (Case 2)
3. T (n) = T (n/2) + 2n =⇒ Θ(2n ) (Case 3)
4. T (n) = 2n T (n/2) + nn =⇒ Does not apply (a is not constant)
5. T (n) = 16T (n/4) + n =⇒ T (n) = Θ(n2 ) (Case 1)
6. T (n) = 2T (n/2) + n log n =⇒ T (n) = n log2 n (Case 2)
7. T (n) = 2T (n/2) + n/ log n =⇒ Does not apply (non-polynomial difference between f (n) and nlogb a )
8. T (n) = 2T (n/4) + n0.51 =⇒ T (n) = Θ(n0.51 ) (Case 3)
9. T (n) = 0.5T (n/2) + 1/n =⇒ Does not apply (a < 1)
10. T (n) = 16T (n/4) + n! =⇒ T (n) = Θ(n!) (Case 3)
11. T (n) =

√
√
2T (n/2) + log n =⇒ T (n) = Θ( n) (Case 1)

12. T (n) = 3T (n/2) + n =⇒ T (n) = Θ(nlg 3 ) (Case 1)
13. T (n) = 3T (n/3) +

√
n =⇒ T (n) = Θ(n) (Case 1)

14. T (n) = 4T (n/2) + cn =⇒ T (n) = Θ(n2 ) (Case 1)
15. T (n) = 3T (n/4) + n log n =⇒ T (n) = Θ(n log n) (Case 3)
16. T (n) = 3T (n/3) + n/2 =⇒ T (n) = Θ(n log n) (Case 2)
17. T (n) = 6T (n/3) + n2 log n =⇒ T (n) = Θ(n2 log n) (Case 3)
18. T (n) = 4T (n/2) + n/ log n =⇒ T (n) = Θ(n2 ) (Case 1)
19. T (n) = 64T (n/8) − n2 log n =⇒ Does not apply (f (n) is not positive)
20. T (n) = 7T (n/3) + n2 =⇒ T (n) = Θ(n2 ) (Case 3)
21. T (n) = 4T (n/2) + log n =⇒ T (n) = Θ(n2 ) (Case 1)
22. T (n) = T (n/2) + n(2 − cos n) =⇒ Does not apply. We are in Case 3, but the regularity condition is
violated. (Consider n = 2πk, where k is odd and arbitrarily large. For any such choice of n, you can
show that c ≥ 3/2, thereby violating the regularity condition.)

3

Mais conteúdo relacionado

Mais procurados

Mais procurados (16)

Time complexity
Time complexityTime complexity
Time complexity
 
Exemple weibull
Exemple weibullExemple weibull
Exemple weibull
 
Ps02 cmth03 unit 1
Ps02 cmth03 unit 1Ps02 cmth03 unit 1
Ps02 cmth03 unit 1
 
torsionbinormalnotes
torsionbinormalnotestorsionbinormalnotes
torsionbinormalnotes
 
Lesson 7: Vector-valued functions
Lesson 7: Vector-valued functionsLesson 7: Vector-valued functions
Lesson 7: Vector-valued functions
 
Rumus suhu dan kalor
Rumus suhu dan kalorRumus suhu dan kalor
Rumus suhu dan kalor
 
Borut Bajc "Asymptotic safety"
Borut Bajc "Asymptotic safety"Borut Bajc "Asymptotic safety"
Borut Bajc "Asymptotic safety"
 
Trigo cheat sheet_reduced
Trigo cheat sheet_reducedTrigo cheat sheet_reduced
Trigo cheat sheet_reduced
 
ENFPC 2010
ENFPC 2010ENFPC 2010
ENFPC 2010
 
Chapter 2 fourier transform
Chapter 2 fourier transformChapter 2 fourier transform
Chapter 2 fourier transform
 
Nonsmooth and level-resolved dynamics of a driven tight binding model
Nonsmooth and level-resolved dynamics of a driven tight binding modelNonsmooth and level-resolved dynamics of a driven tight binding model
Nonsmooth and level-resolved dynamics of a driven tight binding model
 
Unit 2 power point
Unit 2 power pointUnit 2 power point
Unit 2 power point
 
Learning objects #1
Learning objects #1Learning objects #1
Learning objects #1
 
Sol67
Sol67Sol67
Sol67
 
Kinematika rotasi
Kinematika rotasiKinematika rotasi
Kinematika rotasi
 
Unit 2 power point
Unit 2 power pointUnit 2 power point
Unit 2 power point
 

Semelhante a Master theorm practive problems with solutions

Contemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualContemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualto2001
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.pptMouDhara1
 
Master method theorem
Master method theoremMaster method theorem
Master method theoremRajendran
 
lecture 3
lecture 3lecture 3
lecture 3sajinsc
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrencesMegha V
 
2_Asymptotic notations.pptx
2_Asymptotic notations.pptx2_Asymptotic notations.pptx
2_Asymptotic notations.pptxdattakumar4
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxGadaFarhan
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tablesGaurav Vasani
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutionssubhashchandra197
 
Mathematical formula tables
Mathematical formula tablesMathematical formula tables
Mathematical formula tablesSaravana Selvan
 
RecurrenceAndMasterTheorem.ppt
RecurrenceAndMasterTheorem.pptRecurrenceAndMasterTheorem.ppt
RecurrenceAndMasterTheorem.pptISHAN194169
 

Semelhante a Master theorm practive problems with solutions (20)

Master
MasterMaster
Master
 
Contemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manualContemporary communication systems 1st edition mesiya solutions manual
Contemporary communication systems 1st edition mesiya solutions manual
 
L2
L2L2
L2
 
04_Recurrences_1.ppt
04_Recurrences_1.ppt04_Recurrences_1.ppt
04_Recurrences_1.ppt
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Stirling theorem
Stirling theoremStirling theorem
Stirling theorem
 
lecture 3
lecture 3lecture 3
lecture 3
 
Recurrence relation
Recurrence relationRecurrence relation
Recurrence relation
 
Solving recurrences
Solving recurrencesSolving recurrences
Solving recurrences
 
2_Asymptotic notations.pptx
2_Asymptotic notations.pptx2_Asymptotic notations.pptx
2_Asymptotic notations.pptx
 
T2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptxT2311 - Ch 4_Part1.pptx
T2311 - Ch 4_Part1.pptx
 
3.pdf
3.pdf3.pdf
3.pdf
 
University of manchester mathematical formula tables
University of manchester mathematical formula tablesUniversity of manchester mathematical formula tables
University of manchester mathematical formula tables
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
 
Mathematical formula tables
Mathematical formula tablesMathematical formula tables
Mathematical formula tables
 
Radiation
RadiationRadiation
Radiation
 
Beamer 4.pdf
Beamer 4.pdfBeamer 4.pdf
Beamer 4.pdf
 
501 lecture8
501 lecture8501 lecture8
501 lecture8
 
RecurrenceAndMasterTheorem.ppt
RecurrenceAndMasterTheorem.pptRecurrenceAndMasterTheorem.ppt
RecurrenceAndMasterTheorem.ppt
 

Mais de Kumar

Graphics devices
Graphics devicesGraphics devices
Graphics devicesKumar
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithmsKumar
 
region-filling
region-fillingregion-filling
region-fillingKumar
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xsltKumar
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xmlKumar
 
Xml basics
Xml basicsXml basics
Xml basicsKumar
 
XML Schema
XML SchemaXML Schema
XML SchemaKumar
 
Publishing xml
Publishing xmlPublishing xml
Publishing xmlKumar
 
Applying xml
Applying xmlApplying xml
Applying xmlKumar
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XMLKumar
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee applicationKumar
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLKumar
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB FundmentalsKumar
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programmingKumar
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programmingKumar
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversKumar
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EEKumar
 

Mais de Kumar (20)

Graphics devices
Graphics devicesGraphics devices
Graphics devices
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
region-filling
region-fillingregion-filling
region-filling
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xml
 
Xml basics
Xml basicsXml basics
Xml basics
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DTD
DTDDTD
DTD
 
Applying xml
Applying xmlApplying xml
Applying xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB Fundmentals
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programming
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EE
 

Último

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Último (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Master theorm practive problems with solutions

  • 1. Master Theorem: Practice Problems and Solutions Master Theorem The Master Theorem applies to recurrences of the following form: T (n) = aT (n/b) + f (n) where a ≥ 1 and b > 1 are constants and f (n) is an asymptotically positive function. There are 3 cases: 1. If f (n) = O(nlogb a− ) for some constant > 0, then T (n) = Θ(nlogb a ). 2. If f (n) = Θ(nlogb a logk n) with1 k ≥ 0, then T (n) = Θ(nlogb a logk+1 n). 3. If f (n) = Ω(nlogb a+ ) with > 0, and f (n) satisfies the regularity condition, then T (n) = Θ(f (n)). Regularity condition: af (n/b) ≤ cf (n) for some constant c < 1 and all sufficiently large n. Practice Problems For each of the following recurrences, give an expression for the runtime T (n) if the recurrence can be solved with the Master Theorem. Otherwise, indicate that the Master Theorem does not apply. 1. T (n) = 3T (n/2) + n2 2. T (n) = 4T (n/2) + n2 3. T (n) = T (n/2) + 2n 4. T (n) = 2n T (n/2) + nn 5. T (n) = 16T (n/4) + n 6. T (n) = 2T (n/2) + n log n 1 most of the time, k = 0 1
  • 2. 7. T (n) = 2T (n/2) + n/ log n 8. T (n) = 2T (n/4) + n0.51 9. T (n) = 0.5T (n/2) + 1/n 10. T (n) = 16T (n/4) + n! 11. T (n) = √ 2T (n/2) + log n 12. T (n) = 3T (n/2) + n 13. T (n) = 3T (n/3) + √ n 14. T (n) = 4T (n/2) + cn 15. T (n) = 3T (n/4) + n log n 16. T (n) = 3T (n/3) + n/2 17. T (n) = 6T (n/3) + n2 log n 18. T (n) = 4T (n/2) + n/ log n 19. T (n) = 64T (n/8) − n2 log n 20. T (n) = 7T (n/3) + n2 21. T (n) = 4T (n/2) + log n 22. T (n) = T (n/2) + n(2 − cos n) 2
  • 3. Solutions 1. T (n) = 3T (n/2) + n2 =⇒ T (n) = Θ(n2 ) (Case 3) 2. T (n) = 4T (n/2) + n2 =⇒ T (n) = Θ(n2 log n) (Case 2) 3. T (n) = T (n/2) + 2n =⇒ Θ(2n ) (Case 3) 4. T (n) = 2n T (n/2) + nn =⇒ Does not apply (a is not constant) 5. T (n) = 16T (n/4) + n =⇒ T (n) = Θ(n2 ) (Case 1) 6. T (n) = 2T (n/2) + n log n =⇒ T (n) = n log2 n (Case 2) 7. T (n) = 2T (n/2) + n/ log n =⇒ Does not apply (non-polynomial difference between f (n) and nlogb a ) 8. T (n) = 2T (n/4) + n0.51 =⇒ T (n) = Θ(n0.51 ) (Case 3) 9. T (n) = 0.5T (n/2) + 1/n =⇒ Does not apply (a < 1) 10. T (n) = 16T (n/4) + n! =⇒ T (n) = Θ(n!) (Case 3) 11. T (n) = √ √ 2T (n/2) + log n =⇒ T (n) = Θ( n) (Case 1) 12. T (n) = 3T (n/2) + n =⇒ T (n) = Θ(nlg 3 ) (Case 1) 13. T (n) = 3T (n/3) + √ n =⇒ T (n) = Θ(n) (Case 1) 14. T (n) = 4T (n/2) + cn =⇒ T (n) = Θ(n2 ) (Case 1) 15. T (n) = 3T (n/4) + n log n =⇒ T (n) = Θ(n log n) (Case 3) 16. T (n) = 3T (n/3) + n/2 =⇒ T (n) = Θ(n log n) (Case 2) 17. T (n) = 6T (n/3) + n2 log n =⇒ T (n) = Θ(n2 log n) (Case 3) 18. T (n) = 4T (n/2) + n/ log n =⇒ T (n) = Θ(n2 ) (Case 1) 19. T (n) = 64T (n/8) − n2 log n =⇒ Does not apply (f (n) is not positive) 20. T (n) = 7T (n/3) + n2 =⇒ T (n) = Θ(n2 ) (Case 3) 21. T (n) = 4T (n/2) + log n =⇒ T (n) = Θ(n2 ) (Case 1) 22. T (n) = T (n/2) + n(2 − cos n) =⇒ Does not apply. We are in Case 3, but the regularity condition is violated. (Consider n = 2πk, where k is odd and arbitrarily large. For any such choice of n, you can show that c ≥ 3/2, thereby violating the regularity condition.) 3