FENS103-S03
NP-Hard
Traveling Salesman · Turkey Map
Click a city to add or remove it from the tour. Distances are real (Haversine); travel times assume an average highway speed of 90 km/h.
Optimal
Nearest Neighbor
8 cities · 2,520 routes
Brute Force
Optimal
Tries every possible route. Guaranteed optimal — but the count grows as N!.
Distance
—
Drive time
—
Compute time
—
Gap to optimal
—
≈ < 1 ms estimated
Nearest Neighbor
Heuristic
At each step, jump to the closest unvisited city. Fast — usually ~20–25% above optimal.
Distance
—
Drive time
—
Compute time
—
Gap to optimal
—
O(n²) · finishes in milliseconds
Run
Brute Force ≈ < 1 ms.
How it scales
(N−1)!/2 distinct tours
| N | Routes | BF time |
|---|---|---|
| 5 | 12 | < 1 ms |
| 8 | 2,520 | < 1 ms |
| 10 | 181,440 | 4 ms |
| 12 | 19,958,400 | 399 ms |
| 15 | 43,589,145,600 | 14.5 min |
| 20 | 6.08 × 10^16 | 39 yr |
Currently 2,520 distinct tours.