Skip to content
StackDecode
Dynamic programmingExplained

Travelling Salesman Problem (DP)

Held–Karp: best tour over every subset of visited cities.

Time

O(2ⁿ · n²)

Extra space

O(2ⁿ · n)

Use it for

Exact TSP for up to ~20 cities.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.