Asymptotic Analysis

Asymptotic analysis describes how an algorithm's resource use grows as input size n becomes large. It ignores machine-specific constants when the goal is to compare growth rates, but the definitions are still precise mathematical bounds.[1]

Prerequisites

Prerequisites: functions, inequalities, and limits.

Definition

Let f(n) and g(n) be nonnegative functions for all sufficiently large n .
Usually f(n) is running time or memory use.
Usually g(n) is a simpler comparison function.

Notation

Notation Meaning Formal definition
f(n)=O(g(n)) Asymptotic upper bound There exist constants c>0 and n0 such that 0≤f(n)≤cg(n) for all n≥n0 .
f(n)=Ω(g(n)) Asymptotic lower bound There exist constants c>0 and n0 such that 0≤cg(n)≤f(n) for all n≥n0 .
f(n)=Θ(g(n)) Asymptotically tight bound There exist constants c1,c2>0 and n0 such that 0≤c1g(n)≤f(n)≤c2g(n) for all n≥n0 .

Examples

Worked Example

Show that 5n+20=Θ(n) .

For n≥1 :

5n+20≤25n,

so 5n+20=O(n) with c2=25 . Also:

5n≤5n+20,

so 5n+20=Ω(n) with c1=5 . Since both bounds hold, 5n+20=Θ(n) .

Common Mistakes

Connections

Related note Use
Learning Paths Navigation hub

References


  1. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to Algorithms, 3rd ed., MIT Press, ISBN 978-0-262-03384-8. ↩︎