Download presentation
Presentation is loading. Please wait.
Published byJared Wilson Modified over 9 years ago
1
General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k-1 +... + a 1 n 1 + a 0 = O(n k ) Other functions, try to find the dominant term according to the growth rate of the well known functions Example f(n)=5n 2 +2 n f(n)=5n 2 +3nlog(n)
2
A Hierarchy of Growth Rates
3
A Hierarchy of Growth Rates (cont’d)
4
Theorem The function is big-O of its successors 1 Log b (n) N nLog b (n) N 2 2 n 3 n n! n n
5
Big-Omega Notation Definition: f(n) = (g(n)) if there exist positive constants c and N such that f(n) cg(n) for all n N This says that function f(n) grows at a rate no slower than g(n); thus g(n) is a lower bound on f(n) Note the equivalence – f(n) = (g(n)) iff g(n) = O(f(n)) graph
6
Big-Theta Notation Definition: f(n) = (g(n)) if there exist positive constants c 1, c 2, and N such that c 1 g(n) f(n) c 2 g(n) for all n N Note that f(n) = (g(n)) iff f(n) = O(g(n)) and f(n) = (g(n)) – This says that f(n) grows at the same rate as g(n) Graph
7
Summary of Notations Big-O Notation gives an upper bound for a function to within a constant factor f(n) = O(g(n)) Big-Omega Notation gives a lower bound for a function to within a constant function f(n) = (g(n)) Big-Theta Notation bounds a function to within constant factors f(n) = (g(n))
8
General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k-1 +... + a 1 n 1 + a 0 = O(n k ) Other functions, try to find the dominant term according to the above theorem Example f(n)=5n 2 +2 n f(n)=5n 2 +3nlog(n)
9
Big-O for some algorithms Linear search Binary search
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.