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)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市曹体,隨后出現(xiàn)的幾起案子俗扇,更是在濱河造成了極大的恐慌,老刑警劉巖箕别,帶你破解...
    沈念sama閱讀 212,816評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件铜幽,死亡現(xiàn)場離奇詭異,居然都是意外死亡串稀,警方通過查閱死者的電腦和手機(jī)啥酱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,729評論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來厨诸,“玉大人镶殷,你說我怎么就攤上這事∥⒊辏” “怎么了绘趋?”我有些...
    開封第一講書人閱讀 158,300評論 0 348
  • 文/不壞的土叔 我叫張陵颤陶,是天一觀的道長。 經(jīng)常有香客問我陷遮,道長滓走,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,780評論 1 285
  • 正文 為了忘掉前任帽馋,我火速辦了婚禮闰蚕,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘节沦。我一直安慰自己史煎,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,890評論 6 385
  • 文/花漫 我一把揭開白布吧慢。 她就那樣靜靜地躺著涛漂,像睡著了一般。 火紅的嫁衣襯著肌膚如雪检诗。 梳的紋絲不亂的頭發(fā)上匈仗,一...
    開封第一講書人閱讀 50,084評論 1 291
  • 那天,我揣著相機(jī)與錄音逢慌,去河邊找鬼悠轩。 笑死,一個(gè)胖子當(dāng)著我的面吹牛攻泼,可吹牛的內(nèi)容都是我干的火架。 我是一名探鬼主播,決...
    沈念sama閱讀 39,151評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼坠韩,長吁一口氣:“原來是場噩夢啊……” “哼距潘!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起只搁,我...
    開封第一講書人閱讀 37,912評論 0 268
  • 序言:老撾萬榮一對情侶失蹤音比,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后氢惋,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體洞翩,經(jīng)...
    沈念sama閱讀 44,355評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,666評論 2 327
  • 正文 我和宋清朗相戀三年焰望,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了骚亿。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,809評論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡熊赖,死狀恐怖来屠,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤俱笛,帶...
    沈念sama閱讀 34,504評論 4 334
  • 正文 年R本政府宣布捆姜,位于F島的核電站,受9級特大地震影響迎膜,放射性物質(zhì)發(fā)生泄漏泥技。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,150評論 3 317
  • 文/蒙蒙 一磕仅、第九天 我趴在偏房一處隱蔽的房頂上張望珊豹。 院中可真熱鬧,春花似錦榕订、人聲如沸店茶。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,882評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽忽妒。三九已至玩裙,卻和暖如春兼贸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背吃溅。 一陣腳步聲響...
    開封第一講書人閱讀 32,121評論 1 267
  • 我被黑心中介騙來泰國打工溶诞, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人决侈。 一個(gè)月前我還...
    沈念sama閱讀 46,628評論 2 362
  • 正文 我出身青樓螺垢,卻偏偏與公主長得像,于是被迫代替她去往敵國和親赖歌。 傳聞我的和親對象是個(gè)殘疾皇子枉圃,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,724評論 2 351

推薦閱讀更多精彩內(nèi)容

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