Definition · The travelling salesman problem, as this page states itGiven n cities and a distance from each to each, find a cyclic route that starts at city 1, visits every city exactly once, and returns to city 1, of least total length. The distances need not be symmetric and nothing here assumes the triangle inequality — the lab ships a matrix violating both.
Theorem · The Held-Karp recurrenceFor a subset S of the cities containing city 1 and a city j in S other than 1, let D(S, j) be the length of the shortest path that starts at city 1, visits exactly the cities of S, and ends at j. Then D({1, j}, j) = d(1, j), and for larger S, D(S, j) is the minimum over cities i in S other than 1 and j of D(S − {j}, i) + d(i, j). The tour's length is the minimum over j of D(all, j) + d(j, 1).
A shortest path from city 1 covering S and ending at j arrives at j from some city i in S. Deleting the final leg leaves a path from 1 covering S − {j} and ending at i, and that path must be a shortest such path: a shorter one could be extended by the same final leg to beat the original. So the length is D(S − {j}, i) + d(i, j) for that i, and minimising over i gives the recurrence.
The substitution is legal because the final leg's cost depends only on i and j and not on how S − {j} was traversed, which is exactly the property that makes the order inside a subset irrelevant. Closing the cycle at the end adds the return leg, and taking the minimum over the last city gives the tour.
□
The fill order follows from the recurrence as usual: D(S, j) reads entries for S − {j}, which is a strictly smaller set, so filling by increasing subset size — or, equivalently here, by increasing numeric value of the subset's bit pattern — has every read written. On the lab's four-city instance the fill makes 12 reads.
What comes back, and the convention it follows
The tour is returned as an open list of n cities beginning at city 1. The leg home is counted in the reported length and is not in the list. On the lab's default matrix the tour is 1, 3, 4, 2 and the length is 21; adding up the three legs written down gives 20, and the missing 1 is the return from city 2 to city 1. Re-measuring the list as written is the way to convince yourself there is an off-by-one in the table, and there is not.
So the check closes the cycle. The panel confirms that the list is a permutation of the cities starting at city 1 and re-adds the n legs — the n − 1 written plus the return — from the distance matrix. Both of those are separate from the table, and both are printed.
Example · Four cities, and all six toursThe matrix is asymmetric: the distance from city 1 to city 2 is 2 and from 2 to 1 is 1. The six tours are 1-2-3-4-1 at 22, 1-2-4-3-1 at 33, 1-3-2-4-1 at 26, 1-3-4-2-1 at 21, 1-4-2-3-1 at 34 and 1-4-3-2-1 at 30. Held-Karp returns 21 and the tour 1, 3, 4, 2, and the enumeration agrees on both.
Where the table loses, and by how much
Held-Karp fills one entry per (subset, end city) pair, which is n2ⁿ entries, and each entry minimises over up to n predecessors, so the work is n²2ⁿ. Trying every ordering is (n−1)! tours. At four cities those are 256 and 6. At five, 800 and 24. At six, 2 304 and 120. At nine, 41 472 and 40 320 — still behind. At ten, 102 400 and 362 880, and from there the gap widens for ever.
This is the Subject's warning in its sharpest available form, and it is worth being precise about what each number is. The two figures on the panel are exact integers evaluated from n, not measurements of a running time and not estimates: n²2ⁿ and (n−1)! are the two bounds, printed at the n on screen. They are the proved statements, and they are what says the table wins eventually. What the lab measures is separate: 12 reads for the fill and 6 tours for the enumeration on this instance, and by that measurement too the table is the slower method here.
So a reader who chose Held-Karp for a four-city problem chose the asymptotically better algorithm and did more work, and would keep doing more work up to nine cities. Nothing is wrong with the analysis. What is wrong is treating an asymptotic comparison as advice about an instance, and this page is on the course because that mistake is invisible when both methods finish instantly.
Intractability and Approximation takes this further: O(n²2ⁿ) is still exponential and this problem is NP-hard, so the table is a better exponential rather than a way out of one. The six honest responses to a problem with no fast algorithm are that course's subject, and an exact algorithm that is merely less bad is the first of them.