The most direct way to solve TSP would be to try all
permutations and find which path is the shortest. This method
is called a brute force search, an exhaustive search
guaranteeing a global optimal solution by systematically
generating all possible routes for a given search space and
comparing each candidate to find the shortest one. While a
brute-force search is simple to implement and it always finds
the shortest route if it exists, its cost is proportional to the size
of search space (i.e. the number of candidate solutions). The
search space tends to grow very quickly as the number of the
locations in the route increases and the brute force approach to
check all possible routes become impractical as the number of
location grows, easily outstripping the capabilities of the fastest
computers. The running time for this approach lies within a
polynomial factor of O(n!), the factorial of the number of
locations. With 10 cities, there are more than 300,000 different
routes. With 15 cities, the number of possibilities balloons to
more than 87 billion. As a result, brute-force search
becomes completely impractical even for 20 locations and is
typically used when the problem size is limited to only a few.
Other approaches for optimal solution such as dynamic
programming (Held–Karp algorithm), linear programming
, and various branch-and-bound algorithms were developed
to improve the time bounds, which seems to be difficult to
achieve.