1 / 20

Advance Data Structure and Algorithm COSC600-101-FA14

Advance Data Structure and Algorithm COSC600-101-FA14. Dr. Yanggon Kim Chapter 2 Algorithm Analysis. Algorithm Analysis. General, This Chapter learn for Running-time. How to estimate the time required for a program.

devona
Download Presentation

Advance Data Structure and Algorithm COSC600-101-FA14

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. Advance Data Structure and AlgorithmCOSC600-101-FA14 Dr. Yanggon Kim Chapter 2 Algorithm Analysis

  2. Algorithm Analysis • General, This Chapter learn for Running-time. • How to estimate the time required for a program. • How to reduce the running time of a program from day or years to fractions of a second. • The results of careless use of recursion. • Very efficient algorithms to raise a number to a power and to compute the greatest common divisor of two numbers.

  3. Analysis of Algorithm -> Use running-time • Worst-case running-time • Average-case running-time (Expected)running –time Use T(n) More simplifying “abstract” T1(N) = 2 + 5N + 100 for algm1 T2(N) = 3+ 5N + 100 for algm2 “Higest Fact”

  4. Asymptotic Notation Convenient for describing the worst-case running-time f(n), T(n) Function ① Big-Oh - O(N) ②Big-Omega - Ω(N) ③Big-Theta - ϴ(N) ④Little-Oh - o(N)

  5. Function(Continued) ① Big-Oh - O(N) (Asymptotic Upper-bound) T(N) = O(f(N)) If these are positive constant C and s.t T(N) ≤ C∙f(N) when N≥ T(N) T T(N) N

  6. Function(Continued) T(N) = 2 + 100 - 5N + 500 = O()  f(n)= = O () = O () ex)T(N) = 2∙logN + 500,000 = O(logN) = O(N) = O()

  7. Function(Continued) ② Big-Omega - Ω(N) (Asymptotic lower-bound) T(N) = Ω(g(N)) If these are positive constant C ≠ s.t T(N) ≥ C∙g(N) when N≥ T(N) T C∙g(N) N

  8. Function(Continued) T(N) = 5∙+ 500 = O(1) = O() = O(log N) = O() = O(log100 N)

  9. Function(Continued) ③ Big-Theta - ϴ(N) (Asymptotic tight-bound) T(N) = ϴ(h(N)) If T(N) = O(h(N)) ≠ T(N) = Ω(H(N)) Ex) T(N) = 3 ∙ + 1000N – 500 = O = () = O() ≠ () = Ω(N) =Ω(log N) =Ω() = ϴ()

  10. Function(Continued) ④Little-Oh T(N) = o(P(N)) If T(N) = o(P(N)) and T(N) ≠ ϴ(P(N)) Rule1 If T1(N) = O(f(N)) ≠ T2(N) = O(g(N)) i) T1(N) + T2(N) = max(O(f(N)) ∙ O(g(N))) ii) T1(N) - T2(N) = O(f(N))∙ g(N)) iii) T1(N) – T2(N) ≠ min(o(f(N)) ∙ o(g(N))) iv) T1(N) / T2(N) ≠ O(f(N)/g(N))

  11. Function(Continued) Rule2 If T(N) is a polynomial of degree K ∙f(n) T(N) = ϴ() ex) T(N) = 5 + 100 =ϴ() Rule3 = = O(N) • logarithm, grow very slowly • Ignore lowen-ove

  12. Function(Continued) ex) T(N) = + 500 + ≠ O( = O() always = O() when a>1

  13. Function(Continued) Hospitals Rules = O -> f(N) =O(g(N)) = C (constant) -> f(N) = O(g(N)) = ∞ -> g(N) =O(f(N)) =osicillate -> no relationship Ex) + O(n) = O() = = O(N) = Ω(log N) = Ω(log N) when k is a positive -100n = ϴ() n≥1

  14. Function(Continued) Ex) stat O; T(1) for(i=0; i<n; i++){ stament1; stament2; T2(N) = 3n stament3; } T(n) = 2+3n+C for(j=0; j<n*n; j++){ = O() stament1; = ϴ() stament2; T3(N) =2 }

  15. Function(Continued) Ex) for(i=0; i<n; i++){ for(j=0; j<i; j++){ stament1; stament2; T(N) = (1+2+3+ ∙∙∙∙∙ +n) ∙ 3 I = 3 ∙ stament10; = O() } = ϴ() }

  16. Function(Continued) Ex) Binary Search let ,, ,∙∙∙∙∙∙, Be seted T(N) = T() + = T() + + = T() + + + = T(1) + ∙ ∙∙∙∙ ∙ + + + -> log n = C ∙ log n = ϴ(log n)

  17. Function(Continued) Divide ≠ cones method General form of T(n) T(n) = a – T() + ϴ() Masten Theorem T(N) = O() if a > = O(∙ if a = = O() if a <

  18. Function(Continued) Ex) Merge N ,∙∙∙∙∙∙, ϴ(N) ,,

  19. Function(Continued) T(n) = 2∙T() + ϴ(n) = O(n ) = 2 ∙ 2∙T() + ϴ() + ϴ(n) = 2 ∙ 2 ∙ 2 ∙T() + () + ϴ() + ϴ(n) = 2∙∙∙∙∙2∙T(1) + = 2 ∙ ≈O(O(n )

  20. Function(Continued) Typical f(n)’s growth rate C N N ∙ N ∙ = where A>1 Faster Faster

More Related