80 likes | 223 Views
This tutorial on Complexity Analysis dives into Big-O Notation, an essential concept in computer science. We explore its definition, the conditions for its application, and its implications for analyzing algorithms as data sizes grow. Through examples, including proofs of specific functions, we demonstrate how to establish whether a function is in Big-O. The focus is on understanding the significance of growth rates in complexity and providing practical exercises to reinforce learning. Equip yourself with the knowledge to analyze computational efficiency!
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: