Some NP and NP-Complete Problems 511
Input A distance matrix dist: [0 . . . n – 1]
2
→ N.
Output A permutation π of [0 . . . n – 1] which minimizes
1
0
n
i
−
=
∑
dist(Π(i), Π(i + 1 mod n))
that is, a tour through n cities 0, 1, . . . , n – 1 of minimal total length. The TSOP is defi nitely not a language.
It rather requires the computation of a function from n by n matrices dist to permutations of n elements.
However, we can associate a language recognition problem with the optimization problem in a artifi cial
way.
Name Traveling Salesman Recognition Problem (TSRP).
Input A distance matrix dist: [0 . . . n – 1]
2
→ N and an integer D.
Question Is there a tour of length at most D, that is, is there a permutation Π of [0 . . . n – 1] such that
1
0
n
i
−
=