path - algorithm to traverse points horizontally and vertically -


2D aircraft has n numbers. A robot wants to visit them all but can only take horizontal or vertical steps, how would it deliver them so that the total distance can be covered?

This is where the distance between each pair of digits is. Y2-y1 + | X2-x1 (Rectiliner distance or is called) It basically means that there is no known skilled solution.

On Wikipedia.

The simplest algorithm is a simple cruel power discovery, where you calculate the distance for each possible permutation, and the minimum find is the time to run the O (N!) It will work up to about 10 points , But it will be very slow for a large number of digits.


Comments

Popular posts from this blog

iphone - How do I make a UIPickerView in a UIActionSheet -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -