1 / 38

Kompleksitas Waktu Asimptotik

Kompleksitas Waktu Asimptotik. CSG3F3 Lecture 5. Intro to asymptotic. f(n)=an 2 + bn + c. Fitting curves to the data. f 1 (n)=0.0007772 n 2 + 0.00305n + 0.001  home computer data f 2 (n)=0.0001724 n 2 + 0.00040n + 0.100  desktop computer data.

albertwhite
Télécharger la présentation

Kompleksitas Waktu Asimptotik

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kompleksitas Waktu Asimptotik CSG3F3 Lecture 5

  2. Intro to asymptotic f(n)=an2 + bn + c RMB/CSG3F3

  3. Fitting curves to the data RMB/CSG3F3

  4. f1(n)=0.0007772 n2 + 0.00305n + 0.001  home computer data f2(n)=0.0001724 n2 + 0.00040n + 0.100  desktop computer data RMB/CSG3F3

  5. Coefficients (a,b,c) associated with particular • computers, • languages, and • compilers RMB/CSG3F3

  6. Introducing the language of O- notation • Dominant terms • Ignoring the constant of proportionality RMB/CSG3F3

  7. O(n2) RMB/CSG3F3

  8. Formal definition RMB/CSG3F3

  9. Asymptotic Notations • Big-oh () • Big-omega () • Big-theta () • Little-oh () • Little-omega () RMB/CSG3F3

  10.  -notation • (g(n))={f(n): there exist positive constants c and nonnegative integer nosuch that 0≤f(n) ≤cg(n) for all n ≥ no} • f(n) = O(g(n)) indicates thatf(n) is a member of the set O(g(n)) RMB/CSG3F3

  11. RMB/CSG3F3

  12. Proof • 100n+5 = O(n2) • 100n+n = 101n, 101n ≤ 101n2, for all n≥5 c=101, no=5 • 100n+5n= 105n, 105n ≤ 105n2, for all n≥1, c=105, no=1 RMB/CSG3F3

  13. T(n)=n+1024=O(n) • T(n)=1+2+…+n=O(n2) • T(n)=10n2+4n+2=O(n2) • T(n)=n2/10+2n=O(2n) • T(n)=6*2n+n2=O(2n) • T(n)=1k+ 2k+…+nk=O(nk+1) • T(n)=log n3= O(log n) RMB/CSG3F3

  14. T(n)=10 log 3n=O(n) • T(n)=2n + 3 2log n=O(n) • T(n)=n!=O(nn) RMB/CSG3F3

  15. -notation • (g(n))={f(n): there exist positive constants c and nonnegative integer nosuch that f(n) ≥cg(n) ≥0 for all n ≥ no} • f(n) = (g(n)) indicates thatf(n) is a member of the set (g(n)) RMB/CSG3F3

  16. RMB/CSG3F3

  17. Proof • n3 = (n2): n3 ≥ cn2 for all n ≥ 0, We can select c=1 and n0=0 • 3n +2 = Ω(n) : 3n + 2 ≥ 3n for n ≥ 1 • 10n2 + 4n + 2 = Ω (n2 ) : 10n2 + 4n + 2 ≥ n2 RMB/CSG3F3

  18. -notation • (g(n)) ={f(n) : there exist positive constants c1, c2, and nonnegative integer nosuch that c2g(n)≥f(n) ≥c1g(n)≥0 for all n ≥ no} • f(n) = (g(n)) indicates thatf(n) is a member of the set (g(n)) RMB/CSG3F3

  19. RMB/CSG3F3

  20. Proof • ½n(n-1)= (n2) • Prove the right inequality (upper bound) ½n(n-1)=½n2-½n ≤ ½n2, for all n ≥ 0 • Prove the left inequality (lower bound) ½n(n-1)=½n2-½n ≥ ½n2-½n ½n, for all n ≥ 2 = ¼n2 c1 = ½, c2 = ¼, n0 =2 RMB/CSG3F3

  21. 3n + 2 = Θ(n) as 3n + 2 ≥ 3n for all n ≥2, and 3n + 2 ≤ 4n for all n ≥2 , so c1 =3, c2 =4 n0 =2. RMB/CSG3F3

  22. o-notation • o(g(n))={f(n) : for any positive constants c >0, there exist a constant no > 0 such that 0≤f(n) <cg(n) for all n ≥ no} • Example: 2n=o(n2), but 2n2≠o(n2) RMB/CSG3F3

  23. -notation • (g(n))={f(n): for any positive constants c>0, there exist a constant no>0 such that f(n) >cg(n) ≥0 for all n ≥ no} • Example: n2/2= (n), but n2/2≠ (n2) RMB/CSG3F3

  24. Property of asymptotic • If f1(n)єO(g1(n)) and f2(n)єO(g2(n)), then f1(n) + f2(n) є O(max(g1(n),g2(n))) • If f1(n)єO(g1(n)) and f2(n)єO(g2(n)), then f1(n)*f2(n) є O(g1(n)*g2(n)) (also work for  and ) RMB/CSG3F3

  25. RMB/CSG3F3

  26. RMB/CSG3F3

  27. RMB/CSG3F3

  28. Asymptotic Analogy RMB/CSG3F3

  29. Complexity Classes RMB/CSG3F3

  30. The Seven Most Important Functions 1.The Constant Function f(n) = c , for some fixed constant c. 2. The Linear Function f(n) = n . 3. The Quadratic Function f(n) = n2 . RMB/CSG3F3

  31. The Seven Most Important Functions 4. Cubic function f(n) = n3 . Polynomials f(n) = a0 + a1 n + a2 n2 + …..+ ad nd integer d is called the degree of the polynomial. 5. Exponential Function f( n) = bn, where b is a positive constant, called the base and the argument n is the exponent. RMB/CSG3F3

  32. The Seven Most Important Functions 6. Logarithm Function f(n) = logb n. 7. N-log-N Function f(n) = n log n. RMB/CSG3F3

  33. Comparing Growth Rates RMB/CSG3F3

  34. Growth of Function Values RMB/CSG3F3

  35. Basic Efficiency Class polynomial exponential RMB/CSG3F3

  36. Exercises • Determine whether the following assertions are true or false • n(n+1)/2 є O(n3) • n(n+1)/2 є O(n2) • n(n+1)/2 є(n3) • n(n+1)/2 є(n) RMB/CSG3F3

  37. References • Levitin, Anany. The design and analysis of algorithms. Pearson Education. 2003. • Cormen., Leiserson., Rivest. Introduction to algorithms. RMB/CSG3F3

  38. Next.. Mathematical analysis of nonrecursive algorithm RMB/CSG3F3

More Related