dynamic programming algorithm for the TSP (travelling salesman problem)