查缺补漏(3) - 算法复杂度

问题1:关于 算法复杂度

KhanAcademy

衡量算法复杂度,一般是指算法花费的时间长短,这取决于input的size和随着input size增长而算法时间增长的速度:

1) The size of its input;

2) The rate of growth: how fast a function grows with the input size.

 

1. 算法复杂度的标记:

$\Theta: $ an asympototic tight bound.类似于上确界的定义

$O:$ an asympototic upper bound.类似于上界的定义

$\Omega:$ an asympototic lower bound.类似于下界的定义

If f(n) is O(g(n)) this means that f(n) grows asymptotically no faster than g(n)

If f(n) is Θ(g(n)) this means that f(n) grows asymptotically at the same rate as g(n)

$\Theta(g(n))$表示当n足够大时,算法在最坏的情况下,存在某常数$k_1,k_2$,使得执行时间会在$k_1\cdot g(n)$和$k_2\cdot g(n)$之间。

 

2. 算法复杂度的大小比较:

constant < logarithmic < linear < polynomial < exponential < factorial

代入具体的数字,有

$\Theta(1) < \Theta(\lg n) < \Theta(n\lg n) < \Theta(n^2) < \Theta(2^n) < \Theta(n!)$

并且$\Theta(n^b) < \Theta(a^n), \forall a > 1, b \geq 1$,$\Theta(n!) > \Theta(a^n), \forall a>1$

转载于:https://www.cnblogs.com/RRRRecord/p/7860092.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值