master theorem

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


  1. Master Theorem Sections 4.3-4.5

  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

  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 π‘ˆ π‘œ = Θ 𝑔 π‘œ

  4. Example 1: Merge Sort Ξ€ π‘ˆ π‘œ = 2π‘ˆ π‘œ 2 + Θ π‘œ Ξ€ Master Theorem: π‘ˆ π‘œ = π‘π‘ˆ π‘œ 𝑐 + 𝑔 π‘œ 𝑏 = 2, 𝑐 = 2 𝑔 π‘œ = Θ(π‘œ) 𝑔 π‘œ = Θ π‘œ log 2 2 = Θ π‘œ Case 2 applies 𝑔 π‘œ = Θ π‘œ log π‘œ

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

  6. Example 3 π‘œ 2 + π‘œ 2 π‘ˆ π‘œ = 3π‘ˆ 𝑔 π‘œ = π‘œ 2 𝑏 = 3 𝑐 = 2 π‘œ log 𝑐 𝑏 = π‘œ 1.585… 𝑔 π‘œ = π‘œ 2 = Ξ© π‘œ 1.585+πœ— , πœ— = 0.2 Regularity condition π‘œ 𝑏𝑔 ≀ 𝑑𝑔 π‘œ , 𝑑 < 1 𝑐 2 π‘œ = 3 4 π‘œ 2 ≀ 𝑑𝑔 π‘œ , 𝑑 = 3 3 2 4 Case 3 applies: π‘ˆ π‘œ = Θ π‘œ 2

  7. Example 4 π‘œ 2 + 2 π‘œ π‘ˆ π‘œ = π‘ˆ 𝑔 π‘œ = 2 π‘œ 𝑏 = 1 𝑐 = 2 π‘œ log 𝑐 𝑏 = 1 𝑔 π‘œ = 2 π‘œ = Ξ© π‘œ 0+πœ— , πœ— = 1 (any value works) Regularity condition π‘œ π‘œ 2 ≀ 𝑑2 π‘œ , 𝑑 = 0.5 𝑏𝑔 = 2 𝑐 Case 3: π‘ˆ π‘œ = Θ 2 π‘œ

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

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

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

  11. Example 8 π‘œ π‘ˆ π‘œ = π‘ˆ 2 + π‘œ 2 βˆ’ cos π‘œ 𝑔 π‘œ = π‘œ 2 βˆ’ cos π‘œ 𝑏 = 1 𝑐 = 2 π‘œ log 𝑐 𝑏 = 1 𝑔 π‘œ = π‘œ 2 βˆ’ cos π‘œ = Ξ©(π‘œ 0+πœ— ) , πœ— = 0.5 Regularity condition π‘œ = π‘œ 2 2 βˆ’ cos π‘œ 𝑏𝑔 < 𝑑 β‹… π‘œ 2 βˆ’ cos π‘œ ? 𝑐 2 2 βˆ’ cos π‘œ 2 < 2𝑑 2 βˆ’ cos π‘œ ?

  12. Example 8 (cont ’) The previous inequality cannot be true because when π‘œ = 2𝑗 β‹… 𝜌 , 𝑗 is an odd integer: 𝜌 LHS= 2 βˆ’ cos 2𝑗 β‹… = 3 2 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

Recommend


More recommend