Answer the question
In order to leave comments, you need to log in
How to sort an array of elements of some set by the minimum distance between them?
There is an array of elements of some set and a given operation of the distance between the elements of this set. The question is how to sort an array so that the distance between two adjacent array elements is minimal.
Answer the question
In order to leave comments, you need to log in
Alexander , i.e. Need to find a sequence in which the sum of the distances of adjacent elements of the array will be minimal? Then, this is the classic traveling salesman problem.
For example, for the problem "Let us have 4 numbers: 1, 10, 2, 8. Let the module of the difference of numbers be the distance" there are two solutions: 1, 2, 8, 10 and 10, 8, 2, 1. It all depends on which point to take as the first.
https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B4%D...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question