Program Analysis, Python and Logarithms
Tyler Moore
CSE 3353, SMU, Dallas, TX
January 29, 2013
These slides have been adapted from the slides written by Prof. Steven Skiena at SUNY Stony Brook, author of Algorithm Design Manual. For more information see http://www.cs.sunysb.edu/~skiena/
Problem of the Day
Find two functions f (n) and g(n) that satisfy the following relationship. If no such f and g exist, write “None”.
1 f (n) = o(g(n)) and f (n) = Θ(g(n)) 2 f (n) = Θ(g(n)) and f (n) = o(g(n)) 3 f (n) = Θ(g(n)) and f (n) = O(g(n)) 4 f (n) = Ω(g(n)) and f (n) = O(g(n))
Hint: what does “little oh” notation mean?
f (n) = o(g(n)) ⇐ ⇒ g(n) dominates f (n) So n2 = o(n3) since n3 dominates n2.
2 / 20
You should come to accept the dominance ranking of the basic functions: n! ≫ 2n ≫ n3 ≫ n2 ≫ n log n ≫ n ≫ √n ≫ log n ≫ 1
3 / 20
Reasoning About Efficiency
Grossly reasoning about the running time of an algorithm is usually easy given a precise-enough written description of the algorithm. When you really understand an algorithm, this analysis can be done in your head. However, recognize there is always implicitly a written algorithm/program we are reasoning about.
4 / 20