80 likes | 210 Views
CSCI 2100B Tutorial 3 Complexity Analysis. Zhiwei Zhang. Complexity Analysis. Big - Oh Notation: The definition : if and only if there exists positive constants and such that for all . The implication :
E N D
CSCI 2100B Tutorial 3Complexity Analysis Zhiwei Zhang
Complexity Analysis • Big - Oh Notation: • The definition: • if and only if there exists positive constants and such that for all . • The implication: • means it cares a large size of data values -- larger than some given number . • means that is smaller than a constant time of the simplified function .
Big - Oh Notation The definition: if and only if there exists positive constants and such that for all . Example1: g(n) = 3*g(n) = O() Reason: By choosing c = 4 and n0 = 2, for all values of N greater than 2: 3 * N2 + 3 <= 4 * N2
Big - Oh Notation g(n) = 3*g(n) = O() g(n) = O() ??? By choosing c = 1 and = 4, g(n) <=
Big - Oh Notation The most important factor of a function is a function which grows fastest. Suppose . In general, . Proof: , for . Example: 0.001 To proof this, we must prove it by the definition of Big Oh
Big - Oh Notation • if and only if there exists positive constants and such that for all . • if there does not exist any positive constants and such that for all . • How to prove this:
Big - Oh Notation • Example: Show that the Big-Oh for g(n) = + 7*n +2 is not O(n) Proof: So there does not exist any positive constants and such that for all .
Big - Oh Notation • More Exercise: