Algorithm for TSP (dynamic programming approach).