Growth of Functions 1 Asymptotic Notation • 충분히 큰 n 에 대하여, 함수 f(n) 을 근사적으로 표현하는 방법 – 알고리즘의 running time 을 표현하기 위하여 사용 • 종류 – – – – – Θ : asymptotic tight bound O : asymptotic lower bound : asymptotic upper bound o : asymptotic strict lower bound ω : asymptotic strict upper bound 2 Asymptotic Notation • Θ notation – Definition f (n) ( g (n)) ↔ there exist positive constants c1 , c2 , no such that 0 c1 g (n) f (n) c2 g (n) n no - Asymptotically tight bound (Ex) 3 Asymptotic Notation • O notation – Definition f (n) O( g (n)) ↔ there exist positive constants c, no such that 0 f (n) cg (n) n no - Asymptotic upper bound Worst-case 의 running time 표현에 적합 - ( g (n)) O( g (n)) (Ex) 4 Asymptotic Notation • Ω notation – Definition f (n) ( g (n)) ↔ there exist positive constants c, no such that 0 cg (n) f (n) n no - Asymptotical lower bound Best-case 의 running time 표현에 적합 (Ex) (Ex) Insertion Sort 알고리즘의 running time: (n) ~ O(n 2 ) 5 Asymptotic Notation • o notation – Definition f n og n ↔ there exist positive constants c, no such that 0 f ( n ) cg ( n ) - Asymptotic strict upper bound Upper bound that is not asymptotically tight lim n f (n) 0 g( n ) (Ex) 6 Asymptotic Notation • ω notation – Definition f n g n ↔ there exist positive constants c, no such that 0 cg ( n ) f ( n ) - Asymptotic strict lower bound Lower bound that is not asymptotically tight lim n f (n) g( n ) (Ex) 7 Comparisons of Functions • Related Properties: – Transitivity: f (n) = (g(n)) and g(n) = (h(n))⇒ f (n) = (h(n)). Same for O, , o, and ω. – Reflexivity: f (n) = ( f (n)). Same for O and . – Symmetry: f (n) = (g(n)) if and only if g(n) = ( f (n)). – Transpose symmetry: f (n) = O(g(n)) if and only if g(n) = ( f (n)). f (n) = ω(g(n)) if and only if g(n) = ω( f (n)). 8 Standard notations and common functions • Monotonicity: – f (n) is monotonically increasing if m ≤ n ⇒ f (m) ≤ f (n). – f (n) is monotonically decreasing if m n ⇒ f (m) ≥ f (n). – f (n) is strictly increasing if m < n ⇒ f (m) < f (n). – f (n) is strictly decreasing if m n ⇒ f (m) > f (n). • Floor and Ceilings: • Modular arithmetic: x – 1 < x x x < x+1 a mod n = a - a/n n 9 Polynomials, Exponentials and Logarithms • Polynomials - - a d n d a d 1 n d 1 a1 n a o f n O n k for some k f n is polynomial ly bounded • Exponentials n - - - a (a 1) exponential 함수는 polynomial 함수에 비하여 급격히 증가 nb n b a n lim n 0 n b o(a n ) n a exponentially bounded => 무한대의 running time 을 갖는 알고리즘 • Logarithms - lg n log 2 n , ln n log e n polynomial 함수는 logarithm 함수에 비하여 급격히 증가 lg b n n lg n lim 0 lg b n o(n a ) a n n a - b f n O lg k n for some k f n is poly - logarithmi cally bounded 10 Polynomials, Exponentials and Logarithms 11
© Copyright 2024 Paperzz