Day 233 · Aug 20

The Traveling Salesman Problem – NP‑hardness

A salesman must visit n cities and return home, minimising total distance. The brute‑force solution checks (n‑1)!/2 routes – impossible for n=100 (≈ 10¹⁵⁷ routes). The problem is NP‑hard: no known polynomial‑time algorithm, but if P=NP then such an algorithm exists. Practical solutions use heuristics (nearest neighbour, genetic algorithms, branch and bound). The TSP appears in drilling circuit boards, genome sequencing, and telescope scheduling. It’s the quintessential optimisation problem and a testbed for AI and operations research.

For 5 cities, how many distinct routes (ignoring starting point and direction) are there? (4!/2 = 12). For 10 cities, it’s 9!/2 = 181,440 – already too many to check by hand.

Practice related topics on DuelMath

Challenge someone →