Is "travelling salesman" really a NP problem?

What the NP complexity class really means is that, theoretically, if you had a way to always know the suspected correct answer, you can verify that this answer is correct in a time that is bounded by polynomial function of the input size (aka "polynomial time" or P)

For example, the decision problem version of integer factorization is: given an integer n, does n have a factor f such that 1 < f < n?

In the cases where n is the product of two approx. equal size primes, this problem bounded by a fixed constant c to the power of n, or cn, and grows really fast as the bit size of n increases. This is exponential growth, not polynomial. However, if we already know the factors of n, multiplying them together and evaluating whether their product is in fact n can be done in polynomial time.

The decision problem version of The Traveling Salesman problem is something like: give a weighted graph g and a maximum weight w, does a Hamiltonian Circuit exist with a weight less than (or equal to) w?

The worst-case for this problem is very exponential. The bounding function is actually the factorial function, f(n) = n!. This function grows much faster than any fixed constant cn.

How does the "easy validating" work with "travelling salesman"?

If you were able to always know the shortest cycle by measure of the weights of the edges, you can add the weights together and compare to w in polynomial time.

Also, because I think it will help people to understand the above better, look at an example of something that is exponential that is not in NP. Take chess or most complex two-player games: does my color win from this position in chess?

The position can be the opening or it can be any other position throughout the game. The only way to actually know if your color wins from that position is the play the game out with all possible sequences of moves considered. The number of moves is another very exponential figure. There is no simpler way to determine a winner other than calculate an exponential amount of possible moves.

/r/learnprogramming Thread