What is NP

Source: Internet
Author: User
Concept:

In computer science, there are a class of problems with polynomial time algorithms, which are called P-problems. For example, the question of the Vatican, the traveling problem of the salesman, and the question of the (Proposition expression) can satisfy the problem, so far, we have not found a class of problems solved by polynomial time algorithms, which are called NP problems.

 

Taking the salesman's travel question as an example, assume that salesman Henry has a task to sell the company's products to six cities and has a travel budget. He has a flight price table in his hand. He wants to go all over the six cities in the figure from City A and return to City A without exceeding the budget. Please help him find the route. If the given budget is plentiful, the task is simple. If the budget is tight, you have to carefully design the route. You have to consider every possible order to minimize travel expenses.

Salesman travel problems
If there are three cities A, B, and C, and there are round-trips between each other, and the starting city is arbitrary, there are six access orders for each city: ABC, ACB, Bac, BCA, cab, and CBA. If there are four cities, there are 24 order, which can be expressed by factorial: 4! = 4 × 3! = 4 × 3 × 2 × 1 = 24; if there are 5 cities, there are 5! = 5 × 4! = 120, similar to 6! = 720. That is, using computers for computing, the probability of this rapid growth is also far more than the processing capability of computing resources, for this, the algorithm complexity expert Stephen. stephen Cook commented: "If there are 100 cities, you need to find 100! No computer is competent for this task. For example, let all the electrons in the Solar System calculate at the frequency of its rotation, even if the sun burns completely. The key to the problem is that some things won't work in practice. "
  
The most difficult problem in NP is the NP complete problem, which has been proved to include the optimal geometric design of telephone networks and the best way to go for grid games. According to the cook theorem, if any NP complete problem can be solved within the polynomial time, all NP problems can be solved within the polynomial time, and so far there is no answer to this question.

 

Supplement: time complexity

The time complexity does not mean how long it takes for a program to solve the problem, but how quickly the program needs to grow when the problem grows. That is to say, for computers with high-speed data processing, the efficiency of processing a specific data cannot be measured in the quality of a program. However, when the data size increases to hundreds of times, whether the program running time is the same, or it is slowed down by hundreds of times or tens of thousands of times. No matter how big the data is, the time it takes for the program to process is always so much. We can say that this program is very good and has the time complexity of O (1), also known as the constant level complexity; the size of the data becomes large and the time spent is also long. the time complexity of this program is O (n), for example, finding the maximum value of N; for example, Bubble sorting, insertion sorting, and so on, which doubles the data size and slows down the time by 4 times, are the complexity of O (N ^ 2. There are also some exhaustive algorithms that take longer to increase in geometric order. This is the exponential complexity of O (a ^ N), or even O (N !) The factorial complexity. There will be no O (2 * n ^ 2) Complexity, because the previous "2" is a coefficient, it will not affect the time growth of the entire program. Similarly, O
(N ^ 3 + N ^ 2) is the complexity of O (N ^ 3. Therefore, we will say that an O (0.01 * n ^ 3) program is less efficient than O (100 * n ^ 2), even when n is very small, the former is better than the latter, but the latter's time grows slowly with the data scale, and the final O (N ^ 3) complexity will far exceed O (N ^ 2 ). We also say that the complexity of O (N ^ 100) is less than that of O (1.01 ^ N.
It is easy to see that the previous several types of complexity are divided into two levels. The latter is much more complex than the former in any case: the other is O (1 ), O (log (n), O (N ^ A), etc. We call it a polynomial level of complexity, because its scale N appears at the bottom number; the other is O (a ^ N) and O (N !) Type complexity. It is non-polynomial level, and its complexity is often unacceptable to computers. When we solve a problem, the algorithms we choose usually need to be Polynomial-level complexity. Non-Polynomial-level complexity requires too much time and often times out, unless the data size is very small.

 

Real NP problems:

The reason for defining NP problems is thatGenerally, only NP problems can be used to find polynomial algorithms..We will not expect a polynomial to verify that a solution is not feasible. There is a polynomial-level algorithm to solve it.. I believe that readers will soon understand that the "NP problem", the most difficult question in informatics, is actually exploring the relationship between NP problems and P problems.
Apparently,All P problems are NP problems.. That is to say,Solving a problem with polynomials is bound to verify the solution of a problem with polynomials.-- Since all the positive solutions are available, you only need to compare them to verify any given solutions. The key is that people want to know whether all NP problems are P problems. We can use a set of points of view to illustrate. If we classify all P-type problems into one set P and divide all NP problems into another set NP, then obviously P belongs to NP. Now, all the research on NP problems is focused on one issue, that is, is there any p = NP? The so-called "NP problem ".

Its P indicates that polynomial is correct. NP is non-deterministic.
The polynomial problem is the non-deterministic problem of polynomial complexity. The so-called "NP problem" is actually a sentence: prove or overturn P = NP.


 

NP is not a NON-POLYNOMIAL, the NP is said to be a NON-POLYNOMIAL, is the hope of life, reading does not seek a great solution. In fact, if you can prove that an NP problem is a problem of NON-POLYNOMIAL, you can get one of those seven million dollars in the middle of the mathematical awards.

The well-known NP problem in mathematics, the complete name is the NP complete problem, that is, the "NP complete" problem. The simple method is NP = P? . The problem lies in the question mark, whether NP is equivalent to p or Np is not equal to P. One of them proves that you can win a million dollar prize. No one has received this award. That is to say, whether the NP problem is polynomial or non-polynomial is inconclusive.

 

What is non-deterministic? Some computing problems are deterministic, such as addition, subtraction, multiplication, division, and so on. You only need to follow the formula to derive the results step by step. However, some problems cannot be calculated step by step. For example, find the problem of a large prime number. Is there a formula that you can calculate step by step based on a set of formulas? What is the next prime number? There is no such formula. For another example, if there is a formula for decomposing the prime factor of a large combination of numbers, we can directly calculate the number of factors corresponding to them? There is no such formula.

 

The answer to this question cannot be directly calculated, but can only be obtained through indirect "Guess calculation. This is also a non-deterministic problem. These questions often involve an algorithm that does not directly tell you what the answer is, but can tell you whether a possible result is the correct answer or not. This can tell you whether the answer is correct or not, if it can be calculated within the polynomial time (polynomial time: the maximum running time is the input value of the polynomial function, it is called the polynomial non-deterministic problem. If all possible answers to this question are correct or not in polynomial time, it is called a completely polynomial non-deterministic question.

 

Non-deterministic questions with full polynomials can be answered using the exhaustive method, which can be tested one by one and finally obtained. However, the complexity of such an algorithm is exponential. Therefore, the computing time increases exponentially as the complexity of the problem increases, and it becomes uncomputable soon. We found that all the completely polynomial non-deterministic problems can be converted into a type of logical operation problems called satisfying problems. Since all possible answers to such questions can be computed within a polynomial time, it is assumed that there is a deterministic algorithm to determine whether such problems exist within the exponential time, can you directly calculate or find the correct answer? This is the famous Np = P? .

 

To solve this conjecture, there are only two possibilities. One is to find an algorithm like this. If you find an algorithm for a specific NP problem, all these problems can be solved, because they can be converted to the same problem. Another possibility is that such an algorithm does not exist. It is necessary to prove from mathematical theory why it does not exist.

 

Reduction (or reduction ").

Simply put, question A can be reduced to question B, that is, Problem B can be used to solve question a, or problem A can be changed to question B. This is an example in introduction to algorithms. For example, there are two problems: solving a one-dimensional one-time equation and solving a one-dimensional quadratic equation. So we can say that the former can be reduced to the latter, that is, knowing how to solve a one-dimensional quadratic equation will certainly be able to solve a one-dimensional equation. We can write two programs that correspond to two problems respectively, so we can find a "rule" and follow this rule to change the input data of the one-dimensional equation program, in the program for solving the quadratic equation of a single element, the two procedures always get the same result. This rule is: the corresponding coefficient of the two equations remains unchanged, and the quadratic coefficient of the quadratic equation is 0. According to this rule, the previous problem is converted into the next problem, and the two problems are equivalent. Similarly, we can say that the Hamilton loop can be reduced to the traveling
Salesman Problem, Traveling Salesman Problem): In the Hamilton loop problem, the distance between the two points is 0. If the two points are not directly connected, the distance is 1, so the problem is converted to whether there is a path with a length of 0 in the TSP problem. The Hamilton loop exists only when there is a zero length loop in the TSP problem.
"Problem A can be reduced to Problem B"Has an important intuitive significance:The time complexity of B is higher than or equal to that of.. That is to say, question a is no more difficult than question B. This is easy to understand. Since problem A can be solved by Problem B, if the time complexity of B is lower than that of A, the algorithm of A can be improved to B, the time complexity of the two is the same. Just as it is more difficult to solve a quadratic equation than to solve a one-dimensional equation, the solution to the former can be used to solve the latter.
Obviously, reduction has an important nature: reduction has the transmission property. If question A can be reduced to question B and question B can be reduced to question C, question a must be reduced to question C. This principle is very simple and you don't have to explain it.
Now let's take a look at the standard concept of reduction. It's easy to understand: If we can find such a rule of change, we can input any program, all can be transformed into the input of program B according to this rule, so that the output of the two programs is the same, so we can say that problem A can be reduced to Problem B.
Of course, what we call "atomicity" refers to Polynomial-time atomicity ), that is, the transformation input method can be completed in polynomial time. The reduction process is meaningful only when it is completed in polynomial time.

NPC Problems

Okay, as we can see from the definition of reduction,One problem is reduced to another. The time complexity increases and the application scope of the problem increases. Through continuous reduction of some problems, we can constantly look for more complex algorithms, but algorithms with a wider application scope can replace low complexity algorithms that can only be used for very small types of problems.. Let's look back at the P and NP problems mentioned above, and think about the transfer of reduction. Naturally, we will ask, if we continue to contract, constantly finding a slightly complex big NP problem that can "eat through" a number of small NP problems, is it possible to find one with the highest time complexity and can "eat through" all
Is such a super NP problem of the NP problem? The answer is yes. That is to say, there is such an NP problem that all NP problems can be reduced to it. In other words, as long as this problem is solved, all NP problems are solved. The existence of such problems is incredible, and even more incredible is that there are more than one such problem. There are many such problems. This type of problem is the legendary NPC problem, that is, the NP-completeness problem. The emergence of the NPC problem has led to a leap in the research of the entire NP problem. We have reason to believe that the NPC problem is the most complicated. Back to the beginning of the full text, we can see that when people want to express an efficient algorithm that does not have a polynomial, they should say that it is a "NPC problem" (that is, the above mentioned: completely polynomial non-deterministic problem ). At this point, my goal has finally been achieved, and I have made a difference between the NP problem and the NPC problem.

Definition of NPC Problems

The definition of the NPC problem is very simple. The problem that meets the following two conditions is the NPC problem.

1. It must be an NP problem;

2. All NP problems can be reduced to it.

It turns out that the NPC problem is also very simple. First, it is proved that it is at least an NP problem, and then it proves that one of the known NPC problems can be reduced to it (the second article defined by the NPC problem can also be satisfied by the reduced transmitter; as for how the First NPC problem came about, I will introduce it later). In this way, it can be said that it is an NPC problem.
Since all NP problems can be reduced to NPC problems, as long as any NPC problem finds a polynomial algorithm, all NP problems can be solved using this algorithm, NP is equal to P. Therefore, it is incredible to find a polynomial algorithm for NPC. Therefore, the previous article said, "It is the existence of the NPC problem that makes people believe in P = NP ". We can intuitively understand that there is no effective polynomial algorithm for the NPC problem, and we can only search by exponential or even factorial complexity.

NP-hard problem

The NP-hard problem is such a problem. It satisfies the second problem defined by the NPC but does not have to satisfy the first one (that is, the NP-hard problem is wider than the NPC problem ). NP-hard is also difficult to find polynomial algorithms, but it is not included in our research because it is not necessarily an NP problem. Even if a polynomial-level algorithm is discovered for the NPC, the NP-hard problem may still be unable to obtain a polynomial-level algorithm. In fact, given that NP-hard has relaxed restrictions, it may be more time-complex than all NPC problems and thus more difficult to solve.

It can be understood that the NP-hard problem is at least as difficult as the NPC problem, so the NP-hard problem must be an NP-hard problem, in fact, NP completeness is the true subset of NP difficulty. In reality, many problems are not NP problems. However, NP completeness is used as the criterion for evaluating the difficulty of the problem.

 

Example:

Do not think that the issue of NPC is an empty discussion. The NPC problem exists. There is indeed a very specific issue of the NPC. It will be introduced later.
The following describes the logic circuit problems. This is the first NPC problem. Other NPC problems are caused by this problem. Therefore, the logical circuit problem is the originator of the NPC problem ".
A logical circuit problem refers to a problem where, given a logical circuit, the question is whether there is an input to make the Output True.
What is logical circuit? A logical circuit consists of several inputs, one output, several "logic gates", and dense wires. Let's take a look at the following example. You will understand it immediately without any explanation.
┌ ── ┐
│ Input 1 ─ → ┐ ── ┐
── ┘ └ → ┤ │
│ Or province → ─ hour
── ┐ ┌ ── → ┤ │ ┌ ── ┐
│ Input 2 bytes → bytes │
── ┘ │ ┌ → Between and between ── → output
└ ── ─ ┘ ┌ → ┤ │
── ┐ ┌ ── ┐ │ └ ── ┘
│ Input 3 bytes → does not exist → ── ─ done
── ┘
This is a simple logical circuit. When input 1, input 2, and input 3 are true, true, false, false, true, or false, the output is true.
Is there a logical circuit that outputs true in any case? Yes. The following is a simple example.
┌ ── ┐
│ Input 1 parameter → ─ accept parameter ── ─ accept
── ┘ ── → ┤ │
│ And then-→ else
── → ┤ │
│ └ ── ┘ │ ┌ ── ┐
│ Sampled → sampled │
── │ And ├ ── → output
│ Input 2 bytes → ─ ┤ ┌ ── ┐ ┌ → ┤ │
── ┘ └ → ┤ Not → ── ┘
── Accept
In the above logic circuit, no matter what the input is, the output is false. In this case, the logical circuit does not have a set of inputs that make the Output True.
Return to the preceding section, specify a logical circuit and ask if there is an input that sets the output to true, which is a logical circuit problem.
The logic circuit problem is an NPC problem. This is strictly proven. It is obviously an NP problem, and it can prove that all NP problems can be reduced to it directly (do not think that there are infinite NP problems that will cause insurmountable difficulties ). The process of proof is quite complex, it probably means that the input and output of any NP problem can be converted into the input and output of the logic circuit (think about the computation of 0 and 1 in the computer ), therefore, for an NP problem, the problem is converted to an input (a feasible solution) that satisfies the true result ).
With the first NPC problem, a lot of NPC problems have emerged, because to prove a new NPC problem, you only need to contract a known NPC problem to it. Later, the Hamilton Circuit became an NPC problem, and the TSP problem also became an NPC problem. Now it has been proved that there are many NPC problems. If any one finds a polynomial algorithm, all NP problems can be solved perfectly. Therefore, P = NP is incredible because of the existence of the NPC problem. P = NP has many interesting things that need to be further explored. The ultimate goal of our generation is to climb the peak of this informatics field. What we need to do now is at least not to confuse concepts.

References:

Http://hi.baidu.com/cugrain/item/c38896ff603f8c6e3c1485fd

Http://blog.sina.com.cn/s/blog_72d91da40100p71n.html

Http://blog.csdn.net/opennaive/article/details/6991370#t2 (Turing Machine and NP)

Http://en.wikipedia.org/wiki/Co-NP

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.