A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Traveling Salesman Problem (TSP)

College Depth 95 in the knowledge graph ☐ I know this ☆ Set as goal
601prerequisites beneath it
See this on the map →
NP-CompletenessClique Problem and Its Variants+2 more→
optimization np-hard routing

Core Idea

The traveling salesman problem asks for the shortest route visiting all cities exactly once and returning home. The decision version (is there a tour of length ≤ k?) is NP-complete. TSP exemplifies an optimization problem whose hardness motivates approximation algorithms: while finding the optimal tour is hard, finding a tour within a constant factor of optimal is tractable for some variants.

Explainer

You know from NP-completeness theory that certain decision problems are maximally hard within NP — no polynomial-time algorithm is known for them, and any polynomial-time algorithm for one would solve all of NP. The Traveling Salesman Problem is a clean, vivid instance of this phenomenon. Imagine a salesperson who must visit n cities, travel each road at most once, and return to the starting city, minimizing total distance. With n = 10, you could exhaustively check all (10-1)!/2 ≈ 181,000 tours. With n = 30, that number exceeds 4 × 10³⁰ — more than the age of the universe in nanoseconds. Brute force is hopeless at scale.

The decision version of TSP asks: is there a tour of length at most k? This is NP-complete — it is in NP (a tour certificate can be verified in polynomial time by summing edge weights), and every NP problem reduces to it. The optimization version (find the shortest tour) is NP-hard: at least as hard as any NP problem, but not itself a decision problem in NP. This distinction matters: NP-completeness applies strictly to decision problems, while NP-hardness captures the difficulty of optimization versions.

Because finding the exact optimum is hard, TSP motivates the study of approximation algorithms — algorithms that run in polynomial time and are guaranteed to find a tour within a fixed factor of optimal. For the *metric TSP* variant (where distances satisfy the triangle inequality), the Christofides algorithm achieves a 3/2-approximation: its tour is never more than 1.5 times the optimal length. This is a celebrated result because it shows that while perfection is out of reach, disciplined approximation is not. For general TSP without the metric constraint, no constant-factor approximation is possible unless P = NP.

TSP also connects to graph theory prerequisites: the problem can be modeled as finding a minimum-weight Hamiltonian cycle in a complete weighted graph. The gap between Hamiltonian cycle (NP-complete to decide existence) and Eulerian circuit (polynomial-time solvable by Hierholzer's algorithm) illustrates how subtle differences in a problem's structure can radically change its computational tractability. TSP is paradigmatic precisely because it is easy to state, practically important in logistics and circuit design, and theoretically intractable — making it a central benchmark for algorithms research.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Introduction to Propositional Logic → Introduction to Predicate Logic (First-Order Logic) → First-Order Logic Syntax → ZFC Axioms Overview → Axiom Schema of Separation → Axiom Schema of Replacement → Von Neumann Ordinals → Hereditarily Finite Sets → Recursive Definitions on Finite Sets → Well-Founded Relations and Transfinite Recursion → The Axiom of Choice and Equivalent Formulations → Axiom of Choice → Well-Ordering Theorem → Infinite Cardinal Numbers → Cantor's Theorem → Uncountability and the Diagonal Argument → The Cantor Set: An Uncountable Nowhere Dense Example → Uncountable Sets and Cantor Diagonalization → The Halting Problem → Computability Reductions → Polynomial-Time Reductions → Lower Bounds Techniques in Computational Complexity → NP-Completeness → The Cook-Levin Theorem → 3-SAT and NP-Completeness via CNF → Clique Problem and Its Variants → Traveling Salesman Problem (TSP)

Longest path: 96 steps · 601 total prerequisite topics

Prerequisites (4)

Leads To (0)

No topics depend on this one yet.