Docsity

The Asymptotic Notation Cheat Sheet, Cheat Sheet of Mathematics for Computing

Toggle sidebar
bg1
6.042/18.062J Mathematics for Computer Science October 19, 2004
Tom Leighton and Ronitt Rubinfeld
The Asymptotic Cheat Sheet
Asymptotic notation consists of six funny symbols used to describe the relative growth
rates of functions. These six symbols are defined in the table below.
f=Θ(g)fgrows at the same rate as gThere exists an n0and constants c1, c2>0such
that for all n > n0,c1g(n)≤|f(n)|≤c2g(n).
f=O(g)fgrows no faster than gThere exists an n0and a constant c > 0such that
for all n > n0,|f(n)|≤cg(n).
f=Ω(g)fgrows at least as fast as gThere exists an n0and a constant c > 0such that
for all n > n0,cg(n)≤|f(n)|.
f=o(g)fgrows slower than gFor all c > 0, there exists an n0such that for all
n > n0,|f(n)|≤cg(n).
f=ω(g)fgrows faster than gFor all c > 0, there exists an n0such that for all
n > n0,cg(n)≤|f(n)|.
f∼g f/g approaches 1 limn→∞ f(n)/g(n) = 1
The ∼and Θnotations are confusingly similar; qualitatively, functions related by ∼
must be even more nearly alike then functions related by Θ. The ωnotation makes the
table nice and symmetric, but is almost never used in practice. Some asymptotic relation-
ships between functions imply other relationships. Some examples are listed below.
f=O(g)and f=Ω(g)⇔f=Θ(g)f=o(g)⇒f=O(g)
f=O(g)⇔g=Ω(f)f=ω(g)⇒f=Ω(g)
f=o(g)⇔g=ω(f)f∼g⇒f=Θ(g)
pf2

Partial preview of the text

Download The Asymptotic Notation Cheat Sheet and more Cheat Sheet Mathematics for Computing in PDF only on Docsity!

6.042/18.062J Mathematics for Computer Science October 19, 2004 Tom Leighton and Ronitt Rubinfeld

The Asymptotic Cheat Sheet

Asymptotic notation consists of six funny symbols used to describe the relative growth rates of functions. These six symbols are defined in the table below.

f = Θ(g) f grows at the same rate as g There exists an n 0 and constants c 1 , c 2 > 0 such that for all n > n 0 , c 1 g(n) ≤ |f (n)| ≤ c 2 g(n).

f = O(g) f grows no faster than g There exists an n 0 and a constant c > 0 such that for all n > n 0 , |f (n)| ≤ cg(n).

f = Ω(g) f grows at least as fast as g There exists an n 0 and a constant c > 0 such that for all n > n 0 , cg(n) ≤ |f (n)|.

f = o(g) f grows slower than g For all c > 0 , there exists an n 0 such that for all n > n 0 , |f (n)| ≤ cg(n).

f = ω(g) f grows faster than g For all c > 0 , there exists an n 0 such that for all n > n 0 , cg(n) ≤ |f (n)|.

f ∼ g f /g approaches 1 lim (^) n→∞ f (n)/g(n) = 1

The ∼ and Θ notations are confusingly similar; qualitatively, functions related by ∼ must be even more nearly alike then functions related by Θ. The ω notation makes the table nice and symmetric, but is almost never used in practice. Some asymptotic relation- ships between functions imply other relationships. Some examples are listed below.

f = O(g) and f = Ω(g) ⇔ f = Θ(g) f = o(g) ⇒ f = O(g) f = O(g) ⇔ g = Ω(f ) f = ω(g) ⇒ f = Ω(g) f = o(g) ⇔ g = ω(f ) f ∼ g ⇒ f = Θ(g)

12 The Asymptotic Cheat Sheet

Limits

The definitions of the various asymptotic notations are closely related to the definition of a limit. As a result, lim (^) n→∞ f (n)/g(n) reveals a lot about the asymptotic relationship between f and g, provided the limit exists. The table below translates facts about the limit of f /g into facts about the asymptotic relationship between f and g.

limn→∞ f (n)/g(n) $= 0, ∞ ⇒ f = Θ(g) lim (^) n→∞ f (n)/g(n) = 1 ⇒ f ∼ g limn→∞ f (n)/g(n) $= ∞ ⇒ f = O(g) lim (^) n→∞ f (n)/g(n) = 0 ⇒ f = o(g) limn→∞ f (n)/g(n) $= 0 ⇒ f = Ω(g) lim (^) n→∞ f (n)/g(n) = ∞ ⇒ f = ω(g)

Therefore, skill with limits can be helpful in working out asymptotic relationships. In particular, recall L’Hospital’s Rule:

If lim n→∞ f (n) = ∞ and lim n→∞ g(n) = ∞, then lim n→∞

f (n) g(n)

= lim n→∞

f ′^ (n) g ′^ (n)

Every computer scientist knows two rules of thumb about asymptotics: logarithms grow more slowly than polynomials and polynomials grow more slowly than exponen- tials. We’ll prove these facts using limits.

Theorem. For all α, k > 0 :

(ln n) k^ = o(n α^ ) (1) n k^ = o((1 + α) n^ ) (2)

Proof.

lim n→∞

(ln n) k n α^

lim n→∞

ln n n α/k

) (^) k =∗

lim n→∞

1 /n (α/k)n α/k−^1

) (^) k

lim n→∞

(α/k)n α/k

) (^) k = 0

lim n→∞

n k (1 + α) n^

lim n→∞

n (1 + α) n/k

) (^) k =∗

lim n→∞

(n/k) · (1 + α) n/k−^1

)k = 0

The starred equalities follow from L’Hospital’s Rule.