CS252 Algorithms Wednesday, 27 March 2024 + Questions + Mathematical definitions of efficiency - O, Ω, ϴ (and exactness vs. sloppiness) (log2 vs. ln vs. log10...) - worst-case analysis - average-case analysis + Let's try it. Let f(n) = n^2 + 3n + 5 Prove: f(n) = O(n^2) Need to find: c > 0, n0 > 0 such that n >= n0 ==> f(n) <= cn^2 Let c = 9 and n0 = 1 Then: n >= n0 ==> n >= 1 ==> n^2 + 3n + 5 <= n^2 + 3n^2 + 5n^2 = 9n^2 ==> f(n) = n^2 + 3n + 5 <= 9 n^2 ==> f(n) <= cn^2 Therefore f is O(n^2) (scratch paper) n >= 1 ==> n^2 >= n Prove: f(n) = Ω(n^2) [DO IT FOR YOURSELF] Let g(n) = 3n^2 Prove: f(n) = Ω(g(n)) + ChatGPT/Claude/CoPilot/Gemini/... - Are they useful? For what? - What do you think the rules should be? - Citation and collaboration Goal: learning Constraint: fairness (including economic fairness) + Notation (and Jeff's preference, which we're ignoring) - Is there a difference between f and f(n)? - What kind of object is O(f(n))? - is, =, ∈ + Miscellaneous notes - n^2, log(n), and bad intuition - what does O(1) mean? (walk through the definition) - what about that absolute value in the ChatGPT proof? + Examples: named or otherwise familiar algorithms for each O(1) O(log n) O(n log n) O(n) O(n^2) O(n^3) O(sqrt(n)) O(log log n) O(2^n)