A travelling salesman has received a list of cities that he must visit in a single journey. He may start and end his tour in any city as long as he visits each city at least once. He doesn't have to start and finish in the same city. The travelling salesman noticed that his fellow travelling salesmen are spending way too much time planning and finding an optimal route. Therefore, he has decided to take a different, more systematic approach to planning his route.
He will first split all the cities into the left half and the right half. If the number of cities is odd, the right half will contain one city more than the left. He will then pick one of the halves and visit all the cities in that half before visiting any of the cities in the other half.
To visit the cities in the selected left/right half, he will split this set of cities into the lower and upper half. In case of an odd number of cities in this set, the upper half will contain an extra city. Again, he will first visit all cities in one of these halves before visiting any of the cities in the other half.
He will continue applying the same logic of alternately splitting the cities in half horizontally and vertically until he obtains the complete path of the journey. Compute the shortest path that visits all cities that the salesman can obtain in this way.