Skip to content

Traveling salesperson problem

Traveling salesperson problem

A salesperson must visit 5 cities, all at varying distances from each other. The salesperson doesn’t need to visit the cities in any particular order, but must visit all of them. What is the shortest possible distance the salesperson can travel to visit all 5 cities?

An algorithm:

This algorithm is O(n!) (factorial time/space) in Big O notation. This is a famous problem. There is no fast known algorithm to solve it.