General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k 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)
A Hierarchy of Growth Rates
A Hierarchy of Growth Rates (cont’d)
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
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
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
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))
General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k 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)
Big-O for some algorithms Linear search Binary search