【算法设计与分析】computational intractability

参考来源:

                 维基百科:https://en.wikipedia.org/wiki/Time_complexity

1  什么是时间复杂度?

时间复杂度 定性描述了算法的运行时间。(并不是表示解决一个问题花了多少时间,而是描述问题规模扩大与算法运行时间增加的关系)

常见的时间复杂度有:

常数时间O(1),如访问数组中的单个元素;

对数时间O(log n),如二分搜索;

线性时间O(n),如对所有元素的求和;

准线性时间O(nlogn),如快排算法;

多项式时间O(n^{k})  k为常数

1.1  多项式时间

An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm.

1.1.1 强多项式时间和弱多项式时间

Strongly polynomial time is defined in the arithmetic model of computation. In this model of computation the basic arithmetic operations (addition, subtraction, multiplication, division, and comparison) take a unit time step to perform, regardless of the sizes of the operands. The algorithm runs in strongly polynomial time if 

  1. the number of operations in the arithmetic model of computation is bounded by a polynomial in the number of integers in the input instance; and
  2. the space used by the algorithm is bounded by a polynomial in the size of the input.

An algorithm which runs in polynomial time but which is not strongly polynomial is said to run in weakly polynomial time.

强多项式时间:算法时间复杂度不会因输入数据的大小改变,而与输入数据的结构复杂度有关。

1.2  非多项式时间

1.2.1 指数时间 O(k^{n})

1.2.2 阶乘时间 O(n!)

1.2.3 伪多项式时间

算法的时间复杂度是关于输入数据的大小的多项式时间,却是输入数据长度的指数时间。如,素数的检测。

2  什么是问题?

P:所有可以由一个确定型图灵机在多项式时间内解决的问题。

2.1 NP

NP:所有可以在多项式时间内验证它的解是否正确的问题/可以在非确定型图灵机上在多项式时间内解决的问题。

2.2 NPC

NP-Complete:一个决定性问题A若是NPC,则表示它对NP是完备的:1、它是一个NP问题;2、其他属于NP的问题都可以多项式时间内归约成它。

只要任意一个NPC问题找到了多项式时间算法,那么NP问题都可以多项式时间内解决,即P=NP。但目前NPC大多只有指数或者阶乘复杂度的算法 or 伪多项式时间算法。

2.3 NPH

NP-Hard:A若是NP-Hard,其他属于NP的问题都可以在多项式时间内归约成它。

2.4 NPC问题的相互推导

 

3 算法复杂性分析

3.1 时间复杂度

一般算法的每次运行输入不同带来的具体复杂度也不同,因此考虑算法在最坏、最好、平均情况下的时间复杂度,其中最坏复杂度比较有实践价值。

而对于类似3N^2+4NlogN+7此类复杂度,当N \rightarrow \infty时,3N^2称为其渐进复杂性。因此可以看出比较两个算法效率时,只要关心渐进复杂性的阶就可以,引入渐进意义下的符号,O,\Omega,\theta,o.

O:存在常数C和自然数N_0,使得N>N_0时有f(N)<=Cg(N),则称f(N)在N充分大时有上界,且g(N)是它的一个上界。f(N)=O(g(n))

\Omega:存在常数C和自然数N_0,使得N>N_0时有f(N)>=Cg(N),则称f(N)在N充分大时有下界,且g(N)是它的一个下界。f(N)=\Omega(g(n))

\thetaf(N)=O(g(n)) + f(N)=\Omega(g(n)), 同阶

o:给定任意\varepsilon>0,都存在正整数N_0,使得N>=N_0时有f(N)/g(N)<\varepsilon\lim_{N\rightarrow \infty}\frac{f(N)}{g(N)}=0.

 

3.2 空间复杂度

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值