P, NP, NP-hard, NPC

Source: Internet
Author: User

P is a type of problem. They can find the certainty of a polynomial complexity.Algorithm.
This means that, within a given limited resource (Computer), resources can use this algorithm to obtain a correct solution to the problem within a polynomial time.

NP problems are more extensive than P problems. They are defined as a class of problems. They can find non-deterministic algorithms with polynomial complexity.
P belongs to NP, that is, if a problem can find a deterministic algorithm of polynomial complexity, there must be a non-deterministic algorithm of polynomial complexity.
However, NP does not prove to be P. For an NP problem, we cannot find a deterministic algorithm with polynomial complexity, but it cannot be said that it does not exist.
Of course, this means that Np = P has not been proved.

NP problems are usually more difficult than P problems, which means that an algorithm cannot be found within a limited resource and can be solved within a polynomial time.
Therefore, in theory, we need to expand the resources to what is needed. Using such a method, we use a certain technique to guess step by step, and finally test the result to see if it is a correct solution that meets the conditions.
This method is guessed, so there is randomness in each running process, and the number of resources is also unknown, so this method is called a non-deterministic algorithm. This algorithm needs to guess

The final result is checked to see if the result is correct. Therefore, non-deterministic algorithms are decision-making problems ).
In the process of non-deterministic algorithms, each step may have many possibilities. It is precisely because there are too many possibilities that it is difficult to complete a deterministic algorithm within the polynomial complexity. However, the uncertain algorithm is

Based on the infinite number of resources, we can allocate computers with so many possibilities to calculate the number of resources at the same time. Therefore, the cost of each time is 1.

In the next step, there are many possibilities under each possibility. Due to the allocation of sufficient resources, only time is required for the result. 1. The algorithm running process can be viewed in the form of a tree. Each guess is a layer. In a layer, there is always a node in the correct solution path. Therefore, as long as the number of layers in the tree is of polynomial complexity, or the number of layers that reach the correct solution (and are verified) is of polynomial complexity

Non-deterministic algorithms are of polynomial complexity.

More accurately, the process of producing the solution is polynomial complexity, and the process of verifying the solution is also polynomial complexity. Therefore, this non-deterministic algorithm is polynomial complexity.

To construct a non-deterministic algorithm, it is generally easier to generate random solutions. The key lies in the process of generating polynomial complexity verification solutions. Therefore, the complexity of non-deterministic algorithms is often concentrated in the verification solution process. Therefore, another explanation of NP is to find an algorithm that verifies the correctness of a solution in polynomial time.

Analyze the time complexity of non-deterministic algorithms:

Among the countless parallel computing tasks, we only care about the correct path generated between the Start Node and the node that outputs the correct result. This is the running time of the non-deterministic algorithm, because after the correct solution is output, all computations are stopped. From an intuitive analysis algorithm, we can regard the result of each guess step as the correct result. Each statement that generates the guess value is equivalent to the corresponding value assignment statement, and the complexity is O (1 ). The execution time of this algorithm is the time when the non-deterministic algorithm runs.

 

NP-hard is a type of problem. All NP problems can be reduced by polynomials. However, NP-hard problems are not necessarily NP problems, such as downtime problems. All NP problems can be converted into output of the downtime problem through polynomial reduction, and the same yes/no result is obtained. For example, if a Boolean variable is set to true, the loop will not be stopped. If it is false, the loop will be exited and the loop will be stopped. In this way, the polynomial reduction algorithm is constructed. However, the downtime problem is not an NP problem because it is not verifiable for random input (the above constructed input is only a small real subset). That is to say, the verification process cannot be completed at polynomial time, so it is not an NP problem.

NP-complete is the type of NP-hard and NP. Due to the reduction of NP-hard, if the NPC solves, all NP problems will be solved.

 

Proof of NPC:

Cook proved that the satisfaction problem was NPC's. We prove that the NPC method only needs to leverage the power of known NPC, without being as tedious as cook.

To prove that the Q problem is NPC, first select a known NPC problem P and convert the input of P to the input of Q through a polynomial time transformation function T. If P, Q results can produce the same yes and no (that is, P <PQ, P can be used as Polynomials to define Q), so Q is a NP-hard problem.

The reason is that if Q can have a polynomial time algorithm, then q + T is also a polynomial time, and this whole produces the same effect as P, that is, P can have a polynomial time algorithm. The original condition is that P is NPC, so Q does not have a polynomial time algorithm.

Then we can prove that Q is NP.

To prove that a problem is NP, We need to cite its input to illustrate that the process of verifying the validity and correctness of input is polynomial time.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.