Asymptotic Notation: Big-Oh, Big-Omega, Big-Theta, Small-Oh, Small-Omega
Big-Oh (upper bond / worst-case)
If there exists positive constants ccc and n0n_0n0, s.t. f(n)≤c⋅g(n)f(n) \le c \cdot g(n)f(n)≤c⋅g(n) for all n≥n0n \geq n_0n≥n0, we can denote this by f(n)=O(g(n))f(n)=O(g(n))f(n)=O(g(n)).
Big-Omega (lower bond / best-case)
If there exists positive constants ccc and n0n_0n0, s.t. f(n)≥c⋅g(n)f(n) \geq c \cdot g(n)f(n)≥c⋅g(n) for all n≥n0n \geq n_0n≥n0, we can denote this by f(n)=Ω(g(n))f(n)=\Omega(g(n))f(n)=Ω(g(n)).
Big-Theta(tight bond / average-case)
If f(n)=O(g(n))f(n)=O(g(n))f(n)=O(g(n)) and f(n)=Ω(g(n))f(n)=\Omega(g(n))f(n)=Ω(g(n)), we define f(n)=Θ(g(n))f(n)=\Theta(g(n))f(n)=Θ(g(n)).
f(n)=Θ(g(n))f(n)=\Theta(g(n))f(n)=Θ(g(n)) if and only if there exists positive constants c1c_1c1, c2c_2c2 and n0n_0n0, s.t. c1⋅g(n)≤f(n)≤c2⋅g(n)c_1 \cdot g(n) \leq f(n) \leq c_2 \cdot g(n)c1⋅g(n)≤f(n)≤c2⋅g(n) for all n≥n0n \geq n_0n≥n0.
Little-Oh
If there exists positive constants ccc and n0n_0n0, s.t. f(n)<c⋅g(n)f(n) < c \cdot g(n)f(n)<c⋅g(n) for all n≥n0n \geq n_0n≥n0, we can denote this by f(n)=o(g(n))f(n)=o(g(n))f(n)=o(g(n)).
Little-Omega
If there exists positive constants ccc and n0n_0n0, s.t. f(n)>c⋅g(n)f(n) > c \cdot g(n)f(n)>c⋅g(n) for all n≥n0n \geq n_0n≥n0, we can denote this by f(n)=ω(g(n))f(n)=\omega(g(n))f(n)=ω(g(n)).
Others
- logn<n<n<n2<n3<2n\log n < \sqrt n < n < n^2 < n^3 < 2^nlogn<n<n<n2<n3<2n
- Special classes of algorithms:
-
- Logarithmic: O(logn)O(\log n)O(logn)
-
- Linear: O(n)O(n)O(n)
-
- Quadratic: O(n2)O(n^2)O(n2)
-
- Polynomial: O(nk)O(n^k)O(nk), k≥1k \geq 1k≥1
-
- Exponential: O(an)O(a^n)O(an), a>1a>1a>1