2. Asymptotic notation

起因:
In the analysis of algorithms, it is common to estimate the running time in the asymptotic sense, that is, to estimate the running time for arbitrarily large inputs.

O-notation.

For a given function g(n), we denote by O(g(n)) the following set of functions.
O(g(n)) = { f (n) : there exist positive constants c and n0 such that 0≤ f(n)≤c·g(n) for all n≥n0}.

If f (n) ∈ O(g(n)), we write f (n) = O(g(n)), and we call g(n) an asymptotic upper bound for f (n).
f (n) = O(g(n)) means that, for large values of n, the function g(n) is an upper bound on f (n), to within a constant factor. In other words, f (n) grows at most as fast as g(n).

證明過程

Ω-notation.

For a given function g(n), we denote by Ω(g(n)) the following set of functions.
Ω(g(n)) = { f (n) : there exist positive constants c and n0 such that 0≤c·g(n)≤ f(n)foralln≥n0}.

If f (n) ∈ Ω(g(n)), we write f (n) = Ω(g(n)), and we call g(n) an asymptotic lower bound for f (n).
f (n) = Ω(g(n)) means that, for large values of n, the function g(n) is a lower bound on f (n), to within a constant factor. That is, f (n) grows at least as fast as g(n).

證明過程

Θ-notation.

For a given function g(n), we denote by Θ(g(n)) the following set of functions.
Θ(g(n)) = { f (n) : there exist positive constants c1, c2 and n0 such that 0≤c1·g(n)≤ f(n)≤c2·g(n)for all n≥n0}.

If f (n) ∈ Θ(g(n)), we write f (n) = Θ(g(n)), and we call g(n) an asymptotically tight bound for f (n).
f (n) = Θ(g(n)) means that, for large values of n, the function f (n) is equal to g(n) to within a constant factor. That is, f (n) and g(n) have the same rate of growth.

證明過程
示意圖

Why do we need n0 ?

The purpose of the n ≥ n0 condition is to avoid inconvenient behavior for small ns.
One example is when f (n) is negative for a small n.

Asymptotic notation in equations

We defined the equal sign of f (n) = O(g(n)) to mean f (n) ∈ O(g(n)).
Note that here “=” is not symmetric: f (n) = O(g(n)) does not imply O(g(n)) = f (n).

  1. When asymptotic notation appears only on the right-hand side of an equation (or inequality), it stands for some anonymous function that we do not want to specify.
Example: 2n^3 + 3n^2 + 5 = 2n^3 + Θ(n^2).
Interpretation: There is some function f (n) in Θ(n^2), 
namely f (n) = 3n^2 + 5, such that 2n^3 +3n^2 +5 = 2n^3 + f(n).
  1. When asymptotic notation appears (also) on the left of an equation, we mean: No matter how the anonymous functions are chosen on the left, there is a way to choose the anonymous functions on the right to make the statement valid.
Example: 2n^3 + Θ(n^2) = Θ(n^3).
Interpretation: For any choice f (n) ∈ Θ(n^2), 
there is a function g(n) ∈ Θ(n^3) such that 2n^3 + f (n) = g(n).
  1. When asymptotic notation appears only on the left, the formula is often invalid.
Example: A statement like O(g(n)) = f (n) is false, 
because O(g(n)) contains more than one function and they cannot all be equal to f (n).

o-notation

o-notation is used to denote an asymptotic upper bound that is not best possible. For a given function g(n), we denote by o(g(n)) the following set of functions.

o(g(n)) = { f (n) : for any positive constant c, there exists a constant n0 such that 0≤ f(n)<c·g(n) for all n ≥ n0}.
f (n) = o(g(n)) means that f (n) grows slower than g(n).

ω-notation

ω-notation is used to denote an asymptotic lower bound that is not best possible. For a given function g(n), we denote by ω(g(n)) the following set of functions.

ω(g(n)) = { f (n) : for any positive constant c there exists a constant n0 such that 0 ≤ c.g(n) < f(n) for alln≥n0}.
n→∞ g(n)
f (n) = ω(g(n)) means that f (n) grows faster than g(n).

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 她二十歲 不夠沉甸甸的年紀(jì) 喜歡夏天 松散的裙擺 褶皺的風(fēng) 和溫柔的午后 ...
    霧笛閱讀 1,173評(píng)論 1 3
  • 樸珍榮-HIGH CUT雜志 榮榮小可愛,小紅帽。 還沒有學(xué)會(huì)上色,不會(huì)畫,哭唧唧。
    蘇小異閱讀 473評(píng)論 0 4
  • 敲窗斜雨無眠夜,曉來惆悵西風(fēng)借。 河漢渡云舟,不知何處流。 梧桐遮望眼,木槿泥中怨。 只把淚沾衣,芬芳與我違。 (...
    銓齋閱讀 735評(píng)論 15 38

友情鏈接更多精彩內(nèi)容