Let4-Recurrences.pptVIP

  • 5
  • 0
  • 约6.01千字
  • 约 27页
  • 2016-09-11 发布于河南
  • 举报
Let4-Recurrences

Simple Review Merge Sort MERGE(A,p,q,r) Analysis of Merge Sort-Θ(nlgn), by Picture of Recursion Tree Telescoping Mathematical Induction Asymptotic Growth O-notation Ω-notation Θ-notation Simple Review Merge Sort MERGE(A,p,q,r) Analysis of Merge Sort-Θ(nlgn), by Picture of Recursion Tree Telescoping Mathematical Induction Asymptotic Growth O-notation Ω-notation Θ-notation Design and Analysis of Algorithms Recurrences(Ch4) Three common cases Compare f(n) with nlogba : 1. f(n) = O(nlogba -ε) for some constantε 0 f(n) grows polynomially slower than nlogba (by an nε factor), Solution: T(n) = Θ(nlogba) 2. f(n) = Θ(nlogbalgkn) for some constant k≥ 0 f(n) and nlogba grow at similar rates, Solution: T(n) = Θ(nlogbalgk+1n) 3. f(n) = Ω((nlogba+ε) for some constantε 0 f(n) grows polynomially faster than nlogba (by an nε factor), and f(n) satisfies the regularity condition that af(n/b) ≤cf(n) for some constant c 1 Solution: T(n) = Θ(f(n)) Master theorem - examples T(n)=9T(n/3)+n a=9, b=3, f(n) = n logba = 2, f(n) = O(nlogba –ε) where ε=1, case 1 T(n) = Θ(nlogba) =Θ(n2) T(n)=T(2n/3)+1 a=1, b=3/2, f(n) = 1 logba = 0, f(n) = Θ(nlogbalgkn) where k = 0, case 2 T(n) = Θ(nlogbalgk+1n) =Θ(lgn) T(n)=3T(n/4)+nlgn a=3, b=4, f(n) = nlgn logba = log43≈0.793, f(n) = Ω(nlogba –ε) where ε≈ 0.2 af(n/b) = 3f(n/4) = 3(n/4)lg(n/4)≤(3/4)nlgn = cf(n) where c = 3/4, case 3 T(n) = Θ(f(n)) =Θ(nlgn) Homework 4.1-1,4.1-6,4.2-1,4.3-2,4.3-3 *Software School of XiDian University *Software School of XiDian University Θ-notation Note: --Similarly, f(n) = Θ(g(n)) corresponds to f(n) = g(n) --We often think of f(n) = O(g(n)) as corresponding to f(n)≤g(n). --Similarly, f(n) = Ω(g(n)) corresponds to f(n) ≥ g(n) Asymptotic Notation in Equations For example, 4n3 + 3n2 + 2n + 1 = 4n3 + 3n2 + Θ(n) = 4n3 + Θ(n2) = Θ(n3) Used to replace functions of lower-order terms to simplify equations/expressions. Or we can do the following: 4n3 + 3n2 + 2n + 1 = 4n3 + f(n2) Wher

文档评论(0)

1亿VIP精品文档

相关文档