您的位置:首页 > 其它

NP 问题初识

2015-02-20 19:30 141 查看
为了正确理解P, NP, NP-complete和NP-hard,我特意准备中文和英文的解释,感觉读完以后,对NP的认识还是非常清晰的!

P: A decision problem that can be solved in polynomial time. That is, given an instance of the problem, the answer yes or no can be decided
in polynomial time.

NP 是 Non-deterministic Polynomial 的缩写(意思就是非确定性的多项式时间),NP 问题通俗来说是其解的正确性能够被很容易检查的问题,这里"很容易检查"指的是存在一个多项式检查算法。

NP: A decision problem where instances of the problem for which the answer is yes have proofs that can be verified in polynomial time.
This means that if someone gives us an instance of the problem and a certificate (sometimes called a witness) to the answer being yes, we can check that it is correct in polynomial time.

NP-complete 问题是所有 NP 问题中最难的问题。它的定义是,如果你可以找到一个解决某个 NP-complete 问题的多项式算法,那么所有的 NP 问题都将可以很容易地解决。

NP-complete: An NP problem 
X
 for which it is possible to reduce any
other NP problem 
Y
 to 
X
 in polynomial time. Intuitively this means that we can solve 
Y
 quickly
if we know how to solve 
X
 quickly. Precisely, 
Y
 is reducible to 
X
 if
there is a polynomial time algorithm 
f
 to transform instances 
y
 of 
Y
 to
instances 
x = f(y)
 of 
X
 in polynomial time with the property that the answer to 
y
 is
yes if and only if the answer to 
f(y)
 is yes.

NP-hard: Intuitively these are the problems that are even harder than the NP-complete problems. Note that NP-hard problems do not have
to be in NP (they do not have to be decision problems). The precise definition here is that a problem 
X
 is NP-hard if there is an NP-complete problem 
Y
 such
that 
Y
 is reducible to 
X
 in polynomial time. But since any NP-complete problem can be reduced to any other NP-complete
problem in polynomial time, all NP-complete problems can be reduced to any NP-hard problem in polynomial time. Then if there is a solution to one NP-hard problem in polynomial time, there is a solution to all NP problems in polynomial time.

有了这些基本的认识以后,我们经常需要证明NP-complete问题,主要分为以下两步骤:

证明A 是NP, 即满足容易被检查这个性质
构造一个从某个已知的 NP-complete 问题 B 到 A 的多项式变换,使得如果 B 能够被容易地求解,A 也能被容易地解决。(即证明NP-hard)
对于证明一个问题是NP-hard,我们经常用到的一个technique是归约(reduction),

P<=Q,这个就表示P is reducible to Q or Q is the reduction from P or P is reduced to Q. P问题可以归约到Q问题。可以把P归约到Q。

这里的reduction的符号可以当成是 比较难易程度的小于等于号,意味着问题Q至少和问题P一样难。

当我们要证明一个问题是NP-hard的时候,我们通常要做的是找到一个NPC问题(就用这个代替NP-complete问题),把这个

NPC问题归约到NP-hard上去,即NPC<=NP-hard。

这里我们归约要做的主要步骤就是:

1.把NPC的input转化到NP-hard的input,即每一个NPC的input,实际上都是一个NP-hard的input。

2.把NP-hard的output转化到NPC的output上来,说明给我一个NP-hard的output,我就能给你一个NPC的output。

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  NP问题