Algorithm for moving points horizontally and vertically

There are n points in the 2D plane. The robot wants to visit all of them, but can only move horizontally or vertically. How should he visit all of them so that the total distance that he covered is minimal?

+3
source share
1 answer

This is a problem with the seller , where the distance between each pair of points is | y2-y1 | + | x2-x1 | (called Rectilinear distance or Manhattan distance ). This is NP-hard , which basically means that there is no known effective solution.

Ways to solve it on Wikipedia.

- , . O (n!). 10 , .

+4

Source: https://habr.com/ru/post/1724836/


All Articles