Some thoughts on NP problem

Source: Internet
Author: User
Tags gcd terminates clever programmer

I. Overview

Recall Euler loop problem, asked to find a path through each edge of the graph exactly once, the problem is linear solvable. The Hamilton Circle problem is to find a simple circle that includes each vertex of the graph. For this problem, no linear algorithm has been found yet.

For the single source of the graph, there is also linear time solvable, but the shortest path problem (Longest-simple-path) has not yet found the linear algorithm.

The change in these problems is actually worse than the description. For these variants, not only are linear algorithms not known, but there are no known algorithms that guarantee polynomial-time operation. Some well-known algorithms for these problems may take exponential time for some situations.

Because of the complexity, my discussion in the following is only informal, so there may be some regret that the discussion is not in place.

In fact, there are a lot of important problems, they are generally equivalent in complexity. These problems form a class called np-complete (np-complete) problem. These np-exact complexity still needs to be determined and is still the most important open problem in computer science. Either there are polynomial-time algorithms, or none of them have polynomial time algorithms.

Two. Difficult and easy

When classifying questions, the first step is to consider demarcation. We see that many problems can be solved by linear time. We also see some O (Logn) run times, but they either assume that some preprocessing has been done (e.g. input data has been read or the data structure has been established), or that it appears in an operation instance. For example, the GCD (Max common factor) algorithm, when used with two numbers m and N, spends O (logn) of time. Since these two numbers are made up of LOGM and Logn bits, the actual time spent by the GCD algorithm is linear for the amount of input data. So, when we measure the elapsed time, we will consider the elapsed time as a function of the amount of input data. In general, it is not expected to run longer than linear time.

On the other hand, there are really difficult problems (so much so that they cannot be solved). But this does not mean that we are waiting for genius to solve the problem of regret. Just as real numbers are not enough to represent X2<0 's solution, it can be proved that computers cannot solve every problem that happens to happen. These "impossible" problems, called undecidable problem, are not a problem.

A special problem that cannot be determined is the downtime problem (halting problem). Is it possible to have the Java compiler have an additional feature that is not only able to check for syntax errors, but also to check all infinite loops? This may seem like a difficult question, but we might expect that if some clever programmer spends enough time, it might be possible to compile this enhanced compiler.

The problem is unpredictable, and the intuitive reason is that such a program may be difficult to check itself. For this reason, sometimes these problems are called recursive recursively undecidable.

If an infinite loop checker can write, it can certainly be used for self-test. Suppose at this point we can write a program called Loop. Loop takes a program p as input and causes P to run itself. If a loop occurs when P itself is running, the phrase Yes is displayed. If p itself is terminated, no is shown naturally. Now, let's move the loop into an infinite loop, at a different angle.

What happens when loop takes itself as input? or loop stops, or does not stop. The problem is that there is a Russell paradox.

According to our definition, if P (p) terminates, loop (p) enters an infinite loop. When P=loop is set, p (p) terminates. At this point, loop (P) should enter an infinite loop, following the loop procedure. Therefore, we must let loop terminate and enter an infinite loop, which is obviously not possible. On the other hand, when P=loop is set, p (p) enters an infinite loop, then loop (p) is bound to terminate, and we get the same set of contradictions. So it can be said that the loop program does not exist.

Three. NP class

NP class is a class that is inferior to the irreducible problem in difficulty. NP stands for non-deterministic polynomial time (nondeterministic polynomial-time). Deterministic machines are executing an instruction at every moment. According to this instruction, the machine is going to execute a subsequent instruction, which is the only certainty. A non-deterministic machine has a choice of subsequent steps. It is free to make whatever choice it wants, and if one of these later steps is the solution that causes the problem, it will always choose the correct step. Therefore, the non-deterministic machine has a good ability to guess and optimize. This is like a very strange model, because no one can build such a machine, also because this machine is an incredible improvement on the standard computer (at this time all the problems become easy to solve). Non-determinism is a very useful theoretical structure. Moreover, non-determinism is not as powerful as people think. For example, even with non-deterministic, it is still not conclusive that the problem is not determined.

A simple way to test whether a problem is NP is to describe the problem in a "Yes/No (yes/no)" language. If we can prove that an arbitrary "yes" instance of a problem is correct in polynomial time, then the problem is NP class. We don't have to worry about "no" instances, because the program always makes the right choice. Therefore, for Hamiltonian problems, an example of "yes" is a simple loop that contains all the vertices in the graph. Given a path, it is a simple matter to verify that it is really Hamiltonian, so the Hamilton circle problem belongs to NP. such as "Is there a simple path with a length greater than k?" Such problems can also be easily verified thereby belonging to the NP. Any path that satisfies this nature can be easily tested.

Because the solution itself obviously provides a validation method, the NP class includes all problems with polynomial time solutions. One would think that since validating a problem is much simpler than calculating an answer, there is a problem in NP that does not have a polynomial-time solution. Such problems have not been discovered so far, so it is entirely possible that non-determinism is not such an important improvement.

And not all of the issues that can be judged are NP. Consider determining whether a graph does not have a Hamiltonian circle problem. Proving that a graph has a Hamiltonian circle is a relatively simple thing--we just need to find one. Yet no one knows how to prove a graph with polynomial time without the Hamiltonian circle. There seems to be only one method left, which is to enumerate and validate. Therefore, the problem of no Hamiltonian circle is not known to belong to NP.

Four. np-Complete questions

In all the problems known to be NP, there is a subset called np-complete problem, which contains the most difficult problem in NP. np-The complete problem has a nature: any of the problems in NP can be attributed to polynomial time Yocheng np-complete problem.

Problem P1 can be attributed to P2 as follows: There is a mapping so that any instance of P1 can be converted to an instance of P2. Solve the P2 and map the answer back to the original answer. As an example, consider entering a number in decimal to a calculator . These decimal numbers are converted to binary numbers, and all calculations are made in binary. Then, turn the final answer into a decimal display. For the P1 that can be polynomial to Yocheng P2, all work associated with the transformation must be done in polynomial time.

np-complete problem is the most difficult NP problem because a np-complete problem can basically be used as a sub-example of any problem in NP, and it costs only the amount of polynomial overhead. Therefore, if any np-complete problem has a polynomial time solution, then every problem in NP must have a polynomial time solution.

Suppose we have a np-complete problem P1, and P2 is known to belong to NP. Further assuming that the P1 polynomial to the Yocheng P2, so that we can solve P1 by P2 more than the cost of polynomial time. Since P1 is np-complete, every problem in NP can be attributed to Yocheng P1. For the closure of polynomial, we see that every problem in NP can be polynomial to Yocheng P2. Therefore, the P2 is np-complete.

Five. Question of the tour salesman

Given a full figure g= (V,e), its edge value and the integer k, is there a simple loop that accesses all vertices and has a total value of less than or equal to K?

The problem with the itinerant salesman is np-complete. It is easy to see that its solution can be checked by polynomial time, of course it belongs to NP. In order to prove that it is np-complete, we can polynomial the Hamilton circle problem to the tour salesman problem. To do this, a new figure G ', G ' and g have the same vertex. For each side of G ' (V, W), if (V, W) ∈g, then it is entitled to 1, otherwise, its right is 2. We choose k=| v|.

Easy to verify, G has a Hamiltonian loop when and only if G ' has a total right for | V| Tour salesman's tour route.

There are now many problems known to be np-complete problems. In order to prove that a new problem is np-complete problem, it must be proved that it belongs to NP, then constructs an appropriate np-complete problem to transform to the problem.

So the first np-complete question is how specifically proven? Because proving one problem is that np-completely needs to transform from another np-complete problem to it, there must be some np-complete problem, which can not be used in the above thinking. The first proven np-complete problem is the problem of gratification (satisfiability) . This problem takes a Boolean expression as input and asks the expression to value true for each variable once assigned.

The problem of satisfaction is of course NP, because it is easy to calculate the value of a Boolean expression and check whether the result is true (true). In 1971, Cook proved the complete problem of np-by directly proving that all the problems in NP can be changed into satisfying problems. To this end, he used the fact that every problem in NP is known: Every problem in NP can be solved by a non-deterministic computer in polynomial time. This formal model of the computer is the Turing machine (Turing machines). Cook pointed out how the machine's movements can be modeled with a lengthy Boolean formula that is extremely complex but still polynomial. The Boolean formula is true when and only if the program that is run by the Turing is given a "yes" answer to its input.

Once the np-problem is proven to be complete, then a large number of new np-complete problems, including some classic problems, are also proven to be np-complete.

In fact, there are many more famous np-complete problems, such as boxing problem, knapsack problem, coloring problem, regiment problem. These np-complete problems are quite extensive, including from the operating system, databases, operations research, logic, etc., especially in the field of graph theory.

Some thoughts on NP problem

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.