Lecture6 Asymptotic Notations
Lecture6 Asymptotic Notations
Asymptotics
• method of describing limiting behavior.
• What are the properties of f (n) as n
becomes very large.
• If f(n) = n2 + 3n, then as n becomes very
large, the term 3n becomes insignificant
compared to n2.
• f(n) is said to be "asymptotically
equivalent to n2, as n → ∞".
Computation Time
• 5n3+4n+3
– Leave the lower order terms 4n+3
– Leave coefficient of leading term 5 in 5n3
– Express the computing time as O(n3)called big Oh
• Let f(n) and g(n) be functions from positive integers to
positive reals. We say f = O(g) (which means that “f
grows no faster than g”) if there is a constant c > 0
such that
f(n) ≤ c*g(n). 5n3+4n+3 ≤6n3
• F is the lower bound and g is the upper bound
Big O
• f1(n) = n2 and f2(n) = 2n + 20
• assuming that these are the computing times
of two algorithms doing the same task, which
is better?
• For n≤5, f1 is smaller; thereafter, f2 is the clear
winner
• This superiority is captured by the big-O
notation: f2 = O(f1); f2 is less than f1
Big O
• f(n)=3n+2
• g(n)=4n
• Such that f(n) is less than g(n) for all n from no
• So f(n) is O(g(n)); f(n)≤C*g(n) for all n from no
• Big O is upper bound of the computing time
6n - 12
t
tmin = 3
3
Cross Over
-12
Omega Ω
• if f(n) is O(g(n)); f(n)≤C*g(n) for all n
from no
• Then f(n) is Ω(g(n)); f(n)≥C*g(n) for all
n from no
• which means that “f grows faster than
g”)
Theta Θ (Average Case)
• C1*g(n) ≤ f(n)≤C2*g(n)
Commonsense rules to simplify rules