什么是np完全问题?为什么它在计算机科学中如此重要?


当前回答

NP代表非确定性多项式时间。

这意味着使用非确定性图灵机(就像常规图灵机,但也包括非确定性“选择”函数)可以在多项式时间内解决问题。基本上,解必须在多边形时间内可测试。如果是这样的话,一个已知的NP问题可以用修改输入的给定问题来解决(一个NP问题可以简化为给定问题),那么这个问题就是NP完全的。

从np完全问题中得到的主要东西是,它不能以任何已知的方式在多项式时间内解决。NP-Hard/NP-Complete是一种表明某些类型的问题在现实时间内无法解决的方法。

编辑:正如其他人所注意到的,np完全问题通常有近似解。在这种情况下,近似解通常给出一个近似界,用特殊的符号告诉我们这个近似有多接近。

其他回答

np完全是一类问题。

P类由那些可以在多项式时间内解决的问题组成。例如,对于某个常数k,它们可以用O(nk)来求解,其中n是输入的大小。简单地说,您可以编写一个在合理时间内运行的程序。

NP类由那些在多项式时间内可验证的问题组成。也就是说,如果我们已知一个可能的解,那么我们可以在多项式时间内检验这个解是否正确。

一些例子是布尔可满足性(或SAT)问题,或哈密顿循环问题。在NP类中有很多已知的问题。

NP完全意味着问题至少和NP中的任何问题一样难。

它对计算机科学很重要,因为它已经证明了NP中的任何问题都可以转化为NP完备中的另一个问题。这意味着任何一个NP完全问题的解都是所有NP问题的解。

安全性中的许多算法依赖于NP困难问题没有已知解的事实。如果能找到解决方案,它肯定会对计算产生重大影响。

我们需要把算法和问题分开。我们编写算法来解决问题,它们以某种方式扩展。虽然这是一种简化,但如果缩放足够好,我们就用“P”来标记算法,如果缩放不够好,就用“NP”来标记算法。

了解我们试图解决的问题,而不是我们用来解决它们的算法,是有帮助的。所以我们说,所有具有良好伸缩算法的问题都是"在P内"的。而那些有一个糟糕的缩放算法的是“NP”。

That means that lots of simple problems are "in NP" too, because we can write bad algorithms to solve easy problems. It would be good to know which problems in NP are the really tricky ones, but we don't just want to say "it's the ones we haven't found a good algorithm for". After all, I could come up with a problem (call it X) that I think needs a super-amazing algorithm. I tell the world that the best algorithm I could come up with to solve X scales badly, and so I think that X is a really tough problem. But tomorrow, maybe somebody cleverer than me invents an algorithm which solves X and is in P. So this isn't a very good definition of hard problems.

尽管如此,NP中仍有许多问题,没有人知道一个好的算法。因此,如果我能证明X是一个特定的问题:一个解决X的好算法也可以用某种迂回的方式,为NP中的所有其他问题提供一个好算法。现在人们可能更相信X是一个棘手的问题。在这种情况下,我们称X为np完全。

np完全问题是一组问题,其中每一个问题都是任意的 其他np问题可以在多项式时间内约简,其解 仍然可以在多项式时间内验证。也就是说,任何NP问题都可以 转化为np完全问题。 非正式地说,NP完全问题是一个NP问题,至少是“难” 和NP中的其他问题一样。

I have heard an explanation, that is:" NP-Completeness is probably one of the more enigmatic ideas in the study of algorithms. "NP" stands for "nondeterministic polynomial time," and is the name for what is called a complexity class to which problems can belong. The important thing about the NP complexity class is that problems within that class can be verified by a polynomial time algorithm. As an example, consider the problem of counting stuff. Suppose there are a bunch of apples on a table. The problem is "How many apples are there?" You are provided with a possible answer, 8. You can verify this answer in polynomial time by using the algorithm of, duh, counting the apples. Counting the apples happens in O(n) (that's Big-oh notation) time, because it takes one step to count each apple. For n apples, you need n steps. This problem is in the NP complexity class.

如果一个问题可以证明它既NP-Hard,又在多项式时间内可验证,那么它就被归类为NP-complete。在不深入讨论NP-Hard的情况下,只要说明某些问题的多项式时间解还没有找到就足够了。也就是说,它需要n!(n !)步来解它们。然而,如果给你一个np完全问题的解,你可以在多项式时间内验证它。

np完全问题的一个经典例子是旅行商问题。”

作者:ApoxyButt 来自:http://www.everything2.com/title/NP-complete

上面NP完全问题的定义是正确的,但我想我可能会对它们的哲学重要性进行抒情,因为还没有人解决这个问题。

几乎你遇到的所有复杂问题都是NP完全的。这门课有一些非常基础的东西,从计算上看和容易解决的问题是不同的。它们有自己的味道,而且不难辨认。这基本上意味着任何适度复杂的算法都不可能精确地解决——调度、优化、包装、覆盖等。

But not all is lost if a problem you'll encounter is NP Complete. There is a vast and very technical field where people study approximation algorithms, which will give you guarantees for being close to the solution of an NP complete problem. Some of these are incredibly strong guarantees -- for example, for 3sat, you can get a 7/8 guarantee through a really obvious algorithm. Even better, in reality, there are some very strong heuristics, which excel at giving great answers (but no guarantees!) for these problems.

请注意,两个非常著名的问题——图同构和因式分解——不知道是P或NP。