Master Theorem Sections 4.3-4.5 Master Theorem Used to solve a - - PowerPoint PPT Presentation

β–Ά
master theorem
SMART_READER_LITE
LIVE PREVIEW

Master Theorem Sections 4.3-4.5 Master Theorem Used to solve a - - PowerPoint PPT Presentation

Master Theorem Sections 4.3-4.5 Master Theorem Used to solve a large class of recurrence relations The general form of the recurrence is: = + , where 1 and > 1 are constants; and


slide-1
SLIDE 1

Master Theorem

Sections 4.3-4.5

slide-2
SLIDE 2

Master Theorem

Used to solve a large class of recurrence relations The general form of the recurrence is: π‘ˆ π‘œ = π‘π‘ˆ Ξ€ π‘œ 𝑐 + 𝑔 π‘œ , where 𝑏 β‰₯ 1 and 𝑐 > 1 are constants; and 𝑔 π‘œ is an asymptotically positive function

slide-3
SLIDE 3

Master Theorem

π‘ˆ π‘œ = π‘π‘ˆ Ξ€ π‘œ 𝑐 + 𝑔 π‘œ

  • 1. If 𝑔 π‘œ = 𝑃 π‘œlog𝑐 π‘βˆ’πœ— for some constant πœ— >

0, then π‘ˆ π‘œ = Θ π‘œlog𝑐 𝑏

  • 2. If 𝑔 π‘œ = Θ π‘œlog𝑐 𝑏 , then

π‘ˆ π‘œ = Θ π‘œlog𝑐 𝑏 lg π‘œ = Θ 𝑔 π‘œ lg π‘œ

  • 3. If 𝑔 π‘œ = Ξ© π‘œlog𝑐 𝑏+πœ— for some constant πœ— >

0, and if 𝑏𝑔

π‘œ 𝑐 ≀ 𝑑𝑔 π‘œ for some constant

𝑑 < 1 and all sufficiently large n, then π‘ˆ π‘œ = Θ 𝑔 π‘œ

slide-4
SLIDE 4

Example 1: Merge Sort

π‘ˆ π‘œ = 2π‘ˆ Ξ€ π‘œ 2 + Θ π‘œ

Master Theorem: π‘ˆ π‘œ = π‘π‘ˆ Ξ€ π‘œ 𝑐 + 𝑔 π‘œ 𝑏 = 2, 𝑐 = 2 𝑔 π‘œ = Θ(π‘œ) 𝑔 π‘œ = Θ π‘œlog2 2 = Θ π‘œ Case 2 applies 𝑔 π‘œ = Θ π‘œ log π‘œ

slide-5
SLIDE 5

Example 2

π‘ˆ π‘œ = 16π‘ˆ

π‘œ 4 + π‘œ

𝑔 π‘œ = π‘œ 𝑏 = 16 𝑐 = 4 π‘œlog𝑐 𝑏 = π‘œ2 𝑔 π‘œ = 𝑃 π‘œ2βˆ’πœ— , πœ— = 0.1 Case 1 applies π‘ˆ π‘œ = Θ π‘œlog𝑐 𝑏 = Θ π‘œ2

slide-6
SLIDE 6

Example 3

π‘ˆ π‘œ = 3π‘ˆ

π‘œ 2 + π‘œ2

𝑔 π‘œ = π‘œ2 𝑏 = 3 𝑐 = 2 π‘œlog𝑐 𝑏 = π‘œ1.585… 𝑔 π‘œ = π‘œ2 = Ξ© π‘œ1.585+πœ— , πœ— = 0.2 Regularity condition 𝑏𝑔

π‘œ 𝑐

≀ 𝑑𝑔 π‘œ , 𝑑 < 1 3

π‘œ 2 2

= 3

4 π‘œ2 ≀ 𝑑𝑔 π‘œ , 𝑑 = 3 4

Case 3 applies: π‘ˆ π‘œ = Θ π‘œ2

slide-7
SLIDE 7

Example 4

π‘ˆ π‘œ = π‘ˆ

π‘œ 2 + 2π‘œ

𝑔 π‘œ = 2π‘œ 𝑏 = 1 𝑐 = 2 π‘œlog𝑐 𝑏 = 1 𝑔 π‘œ = 2π‘œ = Ξ© π‘œ0+πœ— , πœ— = 1 (any value works) Regularity condition 𝑏𝑔

π‘œ 𝑐

= 2

π‘œ 2 ≀ 𝑑2π‘œ, 𝑑 = 0.5

Case 3: π‘ˆ π‘œ = Θ 2π‘œ

slide-8
SLIDE 8

Example 5

π‘ˆ π‘œ = 64π‘ˆ

π‘œ 8 βˆ’ π‘œ2

𝑔 π‘œ = βˆ’π‘œ2 Master Theorem does not apply as 𝑔 π‘œ must be an asymptotically positive function.

slide-9
SLIDE 9

Example 6

π‘ˆ π‘œ = 2π‘ˆ

π‘œ 2 + π‘œ log π‘œ

𝑔 π‘œ = π‘œ/ log π‘œ 𝑏 = 2 𝑐 = 2 π‘œlog𝑐 𝑏 = π‘œ 𝑔 π‘œ = 𝑃 π‘œlog𝑐 𝑏 𝑔 π‘œ = πœ• π‘œlog𝑐 π‘βˆ’πœ— , for any +ve value of πœ— 𝑔 π‘œ β‰  𝑃 π‘œlog𝑐 π‘βˆ’πœ— Master Theorem does not apply

slide-10
SLIDE 10

Example 7

π‘ˆ π‘œ = 2π‘ˆ π‘œ + π‘œ2 𝑔 π‘œ = π‘œ2 𝑏 = 2 𝑐 = 1 Master Theorem does not apply as 𝑐 must be larger than (and not equal to) 1

slide-11
SLIDE 11

Example 8

π‘ˆ π‘œ = π‘ˆ

π‘œ 2 + π‘œ 2 βˆ’ cos π‘œ

𝑔 π‘œ = π‘œ 2 βˆ’ cos π‘œ 𝑏 = 1 𝑐 = 2 π‘œlog𝑐 𝑏 = 1 𝑔 π‘œ = π‘œ 2 βˆ’ cos π‘œ = Ξ©(π‘œ0+πœ—), πœ— = 0.5 Regularity condition 𝑏𝑔

π‘œ 𝑐

= π‘œ

2 2 βˆ’ cos π‘œ 2

< 𝑑 β‹… π‘œ 2 βˆ’ cos π‘œ ? 2 βˆ’ cos π‘œ

2 < 2𝑑 2 βˆ’ cos π‘œ ?

slide-12
SLIDE 12

Example 8 (cont’)

The previous inequality cannot be true because when π‘œ = 2𝑗 β‹… 𝜌, 𝑗 is an odd integer:

LHS=2 βˆ’ cos 2𝑗 β‹…

𝜌 2

= 3 RHS=2𝑑 2 βˆ’ cos 2𝑗 β‹… 𝜌 = 2𝑑 For the inequality to hold 3 ≀ 2𝑑 𝑑 β‰₯

3 2 > 1

But the regularity condition requires 𝑑 < 1

Regularity condition does not hold Master theorem does not apply