What is the travelling salesman problem (TSP)?
Answer
The Travelling Salesman Problem (TSP) asks: given n cities with pairwise distances, find the shortest route that visits every city exactly once and returns to the starting city. It's NP-Hard (optimization) and NP-Complete (decision version). Exact algorithms: (1) Brute force: try all (n-1)!/2 permutations. O(n!) — only feasible for n ≤ 12; (2) Held-Karp DP: O(2ⁿ × n²) — bitmask DP where dp[mask][i] = minimum cost to visit all cities in mask ending at city i. Feasible for n ≤ 20-25; (3) Branch and bound: prune search tree; better in practice for n ≤ 50. Approximation algorithms: (1) Greedy nearest neighbor: always go to the nearest unvisited city. O(n²) but solution can be up to O(log n) worse than optimal; (2) Christofides algorithm: guaranteed 3/2-approximation for metric TSP — find MST, find minimum perfect matching on odd-degree vertices, find Eulerian circuit, shortcut repeated vertices. O(n³); (3) Lin-Kernighan heuristic: local search — the best practical heuristic for large instances. Applications: logistics routing, circuit board drilling, DNA sequencing, genome assembly. TSP is the canonical example of a combinatorial optimization problem — studying it reveals techniques applicable to many hard optimization problems.
Previous
What is the difference between DFS and BFS in terms of space complexity?
Next
What is the difference between greedy algorithms and dynamic programming?