Try   HackMD

Algorithm Chapter 3 - Growth of Functions

Asymptotic notation

O
-notation

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Figure 1. 圖中比較上面的那個函數是

cg(n), 比較下面的函數是
f(n)
g(n)
f(n)
的漸進上限。

  • O(g(n))={f(n):there exist positive constants c and n0 s.t.0f(n)cg(n) for all nn0}
  • 白話文:
    O(g(n))
    是一個函數的集合,這個集合裡面的每一個函數,在參數大到某一個程度 (
    n0
    ) 過後,其函數值都無法超過
    g(n)
    的某整數倍 (
    c
  • 此時,我們稱
    g(n)
    f(n)
    漸進上限 (asymptotic upper bound)
  • 如果
    f(n)O(g(n))
    , 則我們會直接寫作
    f(n)=O(g(n))
  • 舉例:以下函數都是在
    O(n2)
    裏面的函數
    • n2
    • n2+n
    • n2+1000n
    • 1000n2+1000n
    • n
    • n/1000
    • n1.99999
    • n2/lg(lg(lg(n)))

Ω
-notation

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Figure 2. 圖中比較下面的那個函數是

cg(n), 比較上面的函數是
f(n)
g(n)
f(n)
的漸進下限。

  • Ω(g(n))={f(n):there exist positive constants c and n0 s.t.0cg(n)f(n) for all nn0}
  • 白話文:
    O(g(n))
    是一個函數的集合,這個集合裡面的每一個函數,在參數大到某一個程度 (
    n0
    ) 過後,其函數值都不小於
    g(n)
    的某整數倍 (
    c
  • 此時,我們稱
    g(n)
    f(n)
    漸進下限 (asymptotic lower bound)
  • 如果
    f(n)Ω(g(n))
    , 則我們會直接寫作
    f(n)=Ω(g(n))
  • 舉例:以下函數都是在
    Ω(n2)
    裏面的函數
    • n2
    • n2+n
    • n2n
    • n2+1000n
    • n21000n
    • 1000n2+1000n
    • n3
    • n2.00001
    • n2/lg(lg(lg(n)))
    • 22n

Θ
-notation

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Figure 3. 圖中的函數由上到下是

c2g(n)
f(n)
c1g(n)
g(n)
f(n)
的漸進上下限。

  • Θ(g(n))={f(n):there exist positive constants c1,c2 and n0 s.t.0c1g(n)f(n)c2g(n) for all nn0}
  • 白話文:
    O(g(n))
    是一個函數的集合,這個集合裡面的每一個函數,在參數大到某一個程度 (
    n0
    ) 過後,其函數值都會介於
    g(n)
    的某整數倍 (
    c1
    ) 到另一個整數倍 (
    c2
    ) 之間
  • 此時,我們稱
    g(n)
    f(n)
    漸進上下限 (asymptotic tight bound)
  • 如果
    f(n)Θ(g(n))
    , 則我們會直接寫作
    f(n)=Θ(g(n))
  • f(n)=Θ(g(n))
    , 若且唯若
    f(n)=O(g(n))f(n)=Ω(g(n))

o
-notation

  • o(g(n))={f(n):for all positive constants c>0, there exists a constant n0>0 such that 0f(n)<cg(n) for all nn0}
  • 白話文:
    o(g(n))
    是一個函數的集合,無論
    g(n)
    乘上哪一個正數 (
    c
    ),這個集合裡面的每一個函數總是會從某個數字開始 (
    n0
    ),其函數值永遠都小於(沒有等於)
    cg(n)
  • 更好懂的版本:
    limxf(x)g(n)=0
  • 舉例:以下函數都是在
    o(n2)
    裏面的函數
    • n1.9999
    • n2lg(n)
  • 舉例:以下函數都不是
    o(n2)
    裏面的函數
    • n2
    • n21000

ω
-notation

  • ω(g(n))={f(n):for all positive constants c>0, there exists a constant n0>0 such that 0cg(n)<f(n) for all nn0}
  • 白話文:
    o(g(n))
    是一個函數的集合,無論
    g(n)
    乘上哪一個正數 (
    c
    ),這個集合裡面的每一個函數總是會從某個數字開始 (
    n0
    ),其函數值永遠都大於(沒有等於)
    cg(n)
  • 更好懂的版本:
    limxf(x)g(n)=

Asymptotic notation in equations

略。

Comparisons of functions

Relational properties

  • 遞移性 (Transitivity)
    • f(n)=Θ(g(n))
      g(n)=Θ(h(n))
      , 則
      f(n)=Θ(h(n))
    • O
      Ω
      o
      ω
      同理
  • 自反性 (Reflexivity)
    • f(n)=Θ(f(n))
    • O
      Ω
      同理
  • 對稱性 (Symmetry)
    • f(n)=Θ(g(n))
      , 若且唯若
      g(n)=Θ(f(n))
  • 轉置對稱性 (Transpose Symmetry)
    • f(n)=O(g(n))
      , 若且唯若
      g(n)=Ω(f(n))
    • f(n)=o(g(n))
      , 若且唯若
      g(n)=ω(f(n))

Comparisons

  • f(n)=o(g(n))
    , 則
    f(n)
    漸進小於
    g(n)
  • f(n)=ω(g(n))
    , 則
    f(n)
    漸進大於
    g(n)
  • 這樣的比較是沒有三一律的。雖然直覺上來說,我們可能會把
    O
    想成是
    Ω
    想成是
    , 但函數並不像一般的實數,有時候函數是無法拿來比大小的
    • 例如:
      n1+sin(n)
      n
      無法比大小,因為
      1+sin(n)
      會在 0 到 2 之間不斷振盪

Standard notations and common functions

Monotonicity

  • mn
    f(m)f(n)
    , 則我們說
    f(n)
    是單調遞增 (monotonically increasing) 的函數
  • mn
    f(m)f(n)
    , 則我們說
    f(n)
    是單調遞減 (monotonically decreasing) 的函數
  • m<n
    f(m)<f(n)
    , 則我們說
    f(n)
    是嚴格遞增 (strictly increasing) 的函數
  • m<n
    f(m)>f(n)
    , 則我們說
    f(n)
    是嚴格遞減 (strictly decreasing) 的函數

後面是高中數學(???)