Skip to main content

Held-Karp Algorithm

The Held-Karp Algorithm is a dynamic programming method for the Traveling Salesman Problem in Combinatorics. It finds the shortest Hamiltonian cycle by building answers from smaller sets of cities.

Last updated July 2026•Fiveable Content Team

What is the Held-Karp Algorithm?

The Held-Karp Algorithm is a dynamic programming algorithm for solving the Traveling Salesman Problem, or TSP, in Combinatorics. It finds the shortest route that visits each city exactly once and returns to the starting city, which is the same as finding a minimum-cost Hamiltonian cycle in a weighted complete graph.

The big idea is to stop thinking about one full route at a time and instead break the problem into smaller subproblems. For any set of visited cities and a chosen ending city, Held-Karp stores the cheapest way to get there. Then it reuses those stored results instead of recalculating the same partial routes over and over.

That structure is what makes it a dynamic programming algorithm. You usually define a table like dp[S][j], where S is a subset of cities and j is the last city visited. The value means the minimum cost to start at the home city, visit every city in S, and end at j. From there, the algorithm checks every possible previous city in the subset and adds the edge weight into j.

A tiny example makes the setup clearer. Suppose you start at A and want the best route through B, C, and D. Instead of checking every A-B-C-D ordering from scratch, Held-Karp asks: what is the best way to reach C after visiting {B, C}, or reach D after visiting {B, D}? Those smaller answers feed into the larger one.

The tradeoff is that it is exact but still expensive. Its time complexity is O(n^2 2^n), which is much better than trying all n! tours by brute force, but it still grows too fast for large graphs. So in Combinatorics, you study it as a precise method for small and medium TSP instances, and as a model for how dynamic programming can organize a hard graph problem.

One common mistake is to think Held-Karp is a shortcut that makes TSP easy. It does not. It gives the optimal answer more intelligently than brute force, but the exponential number of subsets is still the bottleneck.

Why the Held-Karp Algorithm matters in COMBINATORICS

Held-Karp shows how Combinatorics turns a hard counting and optimization problem into a structured recursion over subsets. That makes it a useful bridge between graph theory and dynamic programming, two areas that show up together a lot in this course.

It also gives you a clean way to think about Hamiltonian cycles. Instead of asking only whether a cycle exists, you can ask which cycle has the lowest total weight. That shift from existence to optimization is a big theme in combinatorics, especially once graphs get weighted.

The algorithm also helps you compare exact methods with practical approximations. Brute force is conceptually simple but absurdly slow, while Held-Karp is still exponential but much smarter about reusing work. Seeing that difference makes it easier to understand why some graph problems are hard even when the rule is easy to state.

If your class moves into route planning, network design, or algorithm design, Held-Karp is one of the clearest examples of how a subset table and a recurrence can solve a real graph problem exactly for small inputs.

Keep studying COMBINATORICS Unit 11

Official unit cheatsheet

open one-pager

How the Held-Karp Algorithm connects across the course

Traveling Salesman Problem

Held-Karp is one exact way to solve the Traveling Salesman Problem. The TSP gives you the optimization goal, namely the shortest tour through all cities, and Held-Karp supplies the dynamic programming method that searches that space more efficiently than brute force. If you know TSP first, Held-Karp feels like the algorithmic version of the same question.

Dynamic Programming

This algorithm is a classic dynamic programming example because it stores answers to overlapping subproblems in a table. You are not just checking routes, you are reusing the best partial route for each subset and endpoint. That reuse is the reason Held-Karp is faster than checking every possible tour from scratch.

Hamiltonian Cycle

Held-Karp is built around the idea of a Hamiltonian cycle, a cycle that visits every vertex exactly once. In a weighted graph, the algorithm does more than detect whether such a cycle exists. It searches for the minimum-cost one, which connects the existence question to optimization.

Christofides Algorithm

Christofides is another Traveling Salesman Problem algorithm, but it is an approximation method rather than an exact one. Comparing it with Held-Karp helps you see the tradeoff between guaranteed optimality and better runtime. Held-Karp is exact but exponential, while Christofides aims for a near-optimal tour more efficiently.

Is the Held-Karp Algorithm on the COMBINATORICS exam?

A problem set question on Held-Karp usually asks you to set up the recurrence, identify the state of the dynamic programming table, or explain why the runtime is exponential. You might be given a small weighted graph and asked to find the minimum tour by filling in subset costs step by step. That means you should know what the subset S represents, what the endpoint j represents, and how the algorithm builds from smaller visited sets to larger ones.

You may also need to connect it to Hamiltonian cycles. If a question asks for the shortest cycle visiting every vertex once, Held-Karp is the exact-method name you should recognize. For short-answer or discussion questions, the useful move is explaining the difference between brute force and subset-based dynamic programming, not just saying that the algorithm is "faster."

The Held-Karp Algorithm vs Traveling Salesman Problem

The Traveling Salesman Problem is the question, find the shortest tour that visits each city once and returns home. Held-Karp is one algorithm for solving that question. A lot of students mix them up, but TSP names the optimization problem while Held-Karp names the dynamic programming method.

Key things to remember about the Held-Karp Algorithm

  • Held-Karp is a dynamic programming algorithm for the Traveling Salesman Problem in Combinatorics.

  • It works by storing the best route for each subset of visited cities and each possible ending city.

  • The algorithm gives an exact minimum-cost Hamiltonian cycle, not just an approximate route.

  • Its runtime is O(n^2 2^n), so it is much better than brute force but still exponential.

  • The main idea is reuse, not guessing every full tour separately.

Frequently asked questions about the Held-Karp Algorithm

What is the Held-Karp Algorithm in Combinatorics?

It is a dynamic programming algorithm used to solve the Traveling Salesman Problem exactly. The algorithm breaks the tour into subset-based subproblems and finds the minimum-cost Hamiltonian cycle in a weighted graph.

How does Held-Karp use dynamic programming?

It stores the best cost to reach a specific city after visiting a specific set of cities. Then it builds larger answers from smaller ones by trying every possible previous city in the subset. That reuse is what makes it dynamic programming.

Is Held-Karp the same as the Traveling Salesman Problem?

No. The Traveling Salesman Problem is the graph optimization problem, while Held-Karp is one algorithm for solving it. The problem asks for the shortest tour, and Held-Karp gives an exact way to compute it for smaller graphs.

Why is Held-Karp still considered hard to use on large graphs?

Because it still has exponential time complexity, O(n^2 2^n). That is much better than checking every permutation, but the number of subsets still grows very quickly as the graph gets larger. For big instances, approximation algorithms are usually more practical.