算法渐近符号

渐近记号-算法

Big-Oh(渐近上界)

∙ \bullet O O O-notation: For a given function g ( n ) (n) (n), we denote O ( g ( n ) ) O(\mathfrak{g}(n)) O(g(n)) the set of functions O ( O( O(g ( n ) ) = { f ( n ) : (n))=\{f(n): (n))={f(n):there exist positive constants c c c and n 0 n_0 n0 such that 0 ≤ f ( n ) ≤ c g ( n ) 0\leq f(n)\leq cg(n) 0f(n)cg(n) for all n ≥ n 0 } n\geq n_0\} nn0}

O

Big-Omega(渐近下界)

∙ \bullet Ω \Omega Ω-notation: For a given function g ( n ) g(n) g(n), we denote Ω ( g ( n ) ) \Omega(\mathfrak{g}(n)) Ω(g(n)) the set of functions Ω ( \Omega( Ω(g ( n ) ) = { f ( n ) : (n))=\{f(n): (n))={f(n):there exist positive constants c c c and n 0 n_0 n0 such that 0 ≤ c 0\leq c 0cg ( n ) ≤ f ( n ) (n)\leq f(n) (n)f(n) for all n ≥ n 0 } n\geq n_0\} nn0}
在这里插入图片描述

Big-Theta(渐近紧界)

∙ \bullet Θ \Theta Θ-notation: For a given function g ( n ) g(n) g(n),we denote Θ ( g ( n ) ) \Theta(\mathfrak{g}(n)) Θ(g(n)) the set of functions Θ ( \Theta( Θ(g ( n ) ) = { f ( n ) : (n))=\{f(n): (n))={f(n):there exist positive constants c 1 , c 2 c_1,c_2 c1,c2 and n 0 n_0 n0 such that 0 ≤ c 1 0\leq c_1 0c1g ( n ) ≤ f ( n ) ≤ c 2 (n)\leq f(n)\leq c_2 (n)f(n)c2g ( n ) (n) (n) for all n ≥ n 0 } n\geq n_0\} nn0}
在这里插入图片描述

∙ \bullet Theorem: For any two functions f ( n ) f(n) f(n) and g ( n ) (n) (n), we have f ( n ) = Θ ( f(n)=\Theta( f(n)=Θ(g ( n ) ) (n)) (n)) if and only if f ( n ) = O ( g ( n ) ) f(n)=O\left(\mathrm{g}(n)\right) f(n)=O(g(n)) and f ( n ) = f(n)= f(n)= Ω ( g ( n ) ) . \Omega\left(\mathrm{g}(n)\right). Ω(g(n)).

Example

Example: How to show that  n 2 / 2 − 3 n = Θ ( n 2 ) ? We must determine positive constants  c 1 , c 2   a n d   n 0  such that c 1 n 2 ≤ n 2 / 2 − 3 n ≤ c 2 n 2 ⇒ c 1 ≤ 1 / 2 − 3 / n ≤ c 2 By choosing  c 1 = 1 / 14 , c 2 = 1 / 2 , a n d   n 0 = 7 , we can verify that  n 2 / 2 − 3 n = 9 ( n 2 ) The key is some choice exists. \begin{aligned}&\text{Example: How to show that }n^2/2-3n=\Theta(n^2)?\\&\text{We must determine positive constants }c_1,c_2\mathrm{~and~}n_0\text{ such that}\\&c_1n^2\leq n^2/2-3n\leq c_2n^2\\&\Rightarrow c_1\leq1/2-3/n\leq c_2\\&\text{By choosing }c_1=1/14,c_2=1/2,\mathrm{and~}n_0=7,\text{we can verify}\\&\text{that }n^2/2-3n=9(n^2)\\&\text{The key is some choice exists.}\end{aligned} Example: How to show that n2/23n=Θ(n2)?We must determine positive constants c1,c2 and n0 such thatc1n2n2/23nc2n2c11/23/nc2By choosing c1=1/14,c2=1/2,and n0=7,we can verifythat n2/23n=9(n2)The key is some choice exists.

Small-Oh(非渐近紧上界)

Small-Omega(非渐近紧下界)

简记

在这里插入图片描述

An interesting fact about logarithm

l o g b 1 n = O ( l o g b 2 n ) log_{b_1}n=O(log_{b_2}n) logb1n=O(logb2n)
For any constant b 1 > 1 _1>1 1>1 and b 2 > 1. \mathfrak{b}_2>1. b2>1.

Because of the above, in computer science, we omit all the constant logarithm bases in big-O. For example, instead of O ( log ⁡ 2 \mathcal{O}(\log_2 O(log2 n), we will simply write O ( log ⁡ \mathcal{O}(\log O(log n)
∙ \bullet Essentially, this says that"you are welcome to put any constant base there, and it will be the same

asymptotically"   .   \textbf{asymptotically" . } asymptotically" . 

⋅ \cdot Obviously, Ω , Θ \Omega,\Theta Ω,Θ also have this property.

  • 22
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值