CSCI2100C-Lecture4-Growth-BigOmegaBigTheta-Slides(1).pdf - Complexity Analysis Growth of Functions Sibo Wang Department of Systems Engineering and

# CSCI2100C-Lecture4-Growth-BigOmegaBigTheta-Slides(1).pdf -...

This preview shows page 1 - 7 out of 22 pages.

CSCI2100C Data Structures Complexity Analysis: Growth of Functions 1 Sibo Wang Department of Systems Engineering and Engineering Management Chinese University of Hong Kong Complexity Analysis: Growth of Functions CSCI2100C Data Structures Tutorial/Lab session Every Thursday, 17:30 - 18:15 (from Week 3), @ERB 602 Week 3: Lab 1 session Announcement Complexity Analysis: Growth of Functions 2 CSCI2100C Data Structures ? 𝑛 = 𝑂(? 𝑛 ) if and only if we can find a positive constant ? and 𝑛 0 such that ? 𝑛 ≤ ? ⋅ ?(𝑛) for all 𝑛 ≥ 𝑛 0 . Recap of Big-Oh Definition Complexity Analysis: Growth of Functions 3 ? ⋅ ?(𝑛) ?(𝑛) 𝑛 0 𝑛 Implication ? ⋅ ?(𝑛) grows faster than ?(𝑛) Since it grows faster, it will surpass ?(𝑛) at some point, and we denote this point as 𝑛 0 CSCI2100C Data Structures Rule ( i): The polynomial rule: The biggest eats all ? 𝑛 = 𝑛 3 + 𝑛 2 + 𝑛 . 𝑛 3 has the biggest power, it eats all other terms Therefore ? 𝑛 = 𝑂(𝑛 3 ) Rule (ii): Product property: The big multiple the big ? 𝑛 = 𝑛 + 1 ⋅ 𝑛 + 𝑛 5 . The first big: 𝑂 𝑛 , The second big: 𝑂(𝑛 5 ) ? 𝑛 = 𝑂 𝑛 ⋅ 𝑛 5 = 𝑂(𝑛 6 ) Rule (iii): Sum property: The bigger of the two big ? 𝑛 = 𝑛 + 1 + 𝑛 + 𝑛 5 . The first big 𝑂(𝑛) , the second big: 𝑂 𝑛 5 ? 𝑛 = 𝑂 max(𝑛, 𝑛 5 ) = 𝑂 𝑛 5 Recap: Big-Oh Rules (i)-(v) Complexity Analysis: Growth of Functions 4 CSCI2100C Data Structures Rule (iv): log only beats constant ? 𝑛 = 𝑛 0.000001 + log 𝑛 1000 = 𝑂(𝑛 0.000001 ) ? 𝑛 = 0.00000001 ⋅ log 𝑛 + 100000 = 𝑂(log 𝑛) Rule (v): exponential beats powers ? 𝑛 = 1.00001 ? + 𝑛 999999 = 𝑂(1.00001 ? ) ? 𝑛 = 3 ? + 4 ? = 𝑂 4 ? Recap: Big-Oh Rules (i)-(v) (cont.) Complexity Analysis: Growth of Functions 5 CSCI2100C Data Structures Prove or disprove: ? 𝑛 = 2𝑛 = 𝑂(𝑛 2 ) Wait a second? Isn’t ? 𝑛 = 2𝑛 = 𝑂(𝑛) ? Recall Big -Oh denotes the upper bound of the grow rate of ?(𝑛) . There might exist many upper bound ? 𝑛 = 2𝑛 = 𝑂(𝑛 ⋅ log 𝑛) = 𝑂 𝑛 2 = 𝑂 𝑛 3 = 𝑂(2 ? ) But we want to find the tightest. We also need the lower bound of the growth rate Practice Complexity Analysis: Growth of Functions 6 Fina a constant ?, 𝑛 0 and such that 2𝑛 ≤ ?𝑛 2 for all 𝑛 ≥ 𝑛 0 ⇔ 2 ≤ ?𝑛 for all 𝑛 ≥ 𝑛 0 .  #### You've reached the end of your free preview.

Want to read all 22 pages?

• Spring '19
• Big O notation, Analysis of algorithms, Computational complexity theory, Big-Oh rules
• • • 