Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is generating all strings permutation NP Complete?

Calculating all string permutations of a given string can be solved in O(n!) by trying all possibilities.

Now, looking at the Travel Salesman Problem, we can solve it by trying all permutations of cities. Lets say we have cities A, B and C. Lets say we start at city A. By calculating all permutations of BC string we get ABC ACB, then we just sum (in polynomial time the distance between AB, CB and CA for the first case...)

So isnt this a reduction of the all strings permutation to the travel salesman problem and isnt it a NP Complete problem?

like image 956
fredcrs Avatar asked Nov 15 '25 16:11

fredcrs


1 Answers

I think you're confusing some concepts:

What you describe is not "reducing the all permutations problem to TSP", but the opposite: reducing TSP to the all permutations problem. What that proves is that generating all permutations is NP-Hard (at least as hard as the hardest NP problem).

To prove something is NP-Complete, you would also have to prove that it's in NP. But this is not true, right out of the gate: NP is a set of decision problems, and the problem you described isn't a decision problem.

See also: What are the differences between NP, NP-Complete and NP-Hard?

like image 67
Loonquawl Avatar answered Nov 17 '25 08:11

Loonquawl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!