90 likes | 210 Views
Learn how to analyze and determine the growth rates of functions using Big-O, Big-Omega, and Big-Theta notations with examples. Understand the hierarchy of growth rates and apply these concepts to different algorithms effectively.
E N D
General rules: Find big-O • f(n) = k = O(1) • f(n) = aknk + ak-1nk-1 + . . . + a1n1 + a0 = O(nk) • Other functions, try to find the dominant term according to the growth rate of the well known functions • Example f(n)=5n2+2n f(n)=5n2+3nlog(n)
Theorem • The function is big-O of its successors • 1 • Logb(n) • N • nLogb(n) • N2 • 2n • 3n • n! • nn
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 c1, c2, and N such that c1g(n)f(n) c2g(n) for all n N • Note that f(n)= (g(n))ifff(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) = aknk + ak-1nk-1 + . . . + a1n1 + a0 = O(nk) • Other functions, try to find the dominant term according to the above theorem • Example f(n)=5n2+2n f(n)=5n2+3nlog(n)
Big-O for some algorithms • Linear search • Binary search