大小關係

Asymptotic Notation

描述兩個函數在輸入n夠大的時候的成長速率關係。
多項式係數、log的底數(log的係數也是)不影響成長速率關係。


簡易growth order定義
\( O \)視為\( \geq \)
\( \Theta \)視為\( = \)
\( \Omega \)視為\( \leq \)
\( o \)視為\( > \)
\( \omega \)視為\( < \)
這裡的大於小於等於,代表growth order的關係,
不代表函數之間大小的關係,

Example:
\( f(n)= 3n^2 +2 \)
\( g(n)=n^2 \)

growth order的關係:
\( f(n)=O(g(n)), c_0=4,n_0=2 \)
並不代表 \( g(n)\geq f(n) \)
ex:
\( 3n^4 = O(n^4) \)
\( 3n^4 = O(n^6) \)
\( \log_{3}n=O(\lg n) \)

big-O

\( f(n)=O(g(n)) \)
\( g(n) \) is asymptotically upper bound of \( f(n) \).

\( \exists c_0,n_0>0 \)
\( \rightarrow \forall n\geq n_0 \; (0\leq f(n)\leq c_0g(n)) \)

big-omega

\( f(n)=\Omega(g(n)) \)
\( g(n) \) is asymptotically lower bound of \( f(n) \).

\( \exists c_0,n_0>0 \)
\( \rightarrow \forall n\geq n_0 \; (0\leq c_0g(n)\leq f(n)) \)

big-theta

\( f(n)=\Theta(g(n)) \)
\( g(n) \) is asymptotically tight bound of \( f(n) \).

\( \exists c_0,c_1,n_0>0 \)
\( \rightarrow \forall n\geq n_0 \; (0\leq c_0g(n)\leq f(n)\leq c_1g(n)) \)

small-o

\( f(n)=o(g(n)) \)
\( g(n) \) is asymptotically strict upper bound of \( f(n) \).

\( \forall c_0>0,\exists n_0>0 \)
\( \rightarrow \forall n\geq n_0 \; (0\leq f(n) < c_0g(n)) \)

small-omega

\( f(n)=\omega(g(n)) \)
\( g(n) \) is asymptotically strict lower bound of \( f(n) \).

\( \forall c_0>0,\exists n_0>0 \)
\( \rightarrow \forall n\geq n_0 \; (0 \leq c_0g(n)< f(n)) \)

image reference


image reference

set

Asymptotic notation 可以視為是函數的集合:
Example:
\( O(n^2)=\{3n^2-1, n^2, n, \log n,\dots\} \)
\( o(n^3)=\{3n^2-1, n^2, n, \log n,\dots\} \)
\( \Omega(n)=\{3n^2-1, n^2, n,\dots\} \)

這裡用=代表growth order的關係,而不是 \( \in \)。
Example:
\( f(n)=3n^2+1 \)
\( g(n)=n^2 \)
\( f(n)=O(g(n)) \), 而不是 \( f(n)\in O(g(n)) \)

exercise



properties

\( f(n)=O(g(n)) \cap f(n)=\Omega(g(n)) \Leftrightarrow f(n)=\Theta(g(n)) \)

proof


\( f(n)=O(g(n)) \rightarrow f(n)+g(n)=O(g(n)) \)