Sorting multidimensional vectors -
if have set of k vectors of n dimensions, how can sort these such distance between each consecutive pair of vectors minimal possible? distance can calculated using euclidian distance, how "sorting" implemented in effective manner?
i'm thinking 1 approach select vector @ random, calculate distance other vectors, pick vector minimizes distance next vector , repeat until vectors have been "sorted". however, greedy search render different results depending on vector start with.
any ideas on how this?
if want 'that distance between each consecutive pair of vectors minimal possible' without randomness, can firstly find 2 closest points (by o(n log n) algo this) - let's say, p , q, search closest points p (let's say, r) , q (let's say, s), compare distance (p,r) , (q,s) , if first smaller, start q,p,r , use greedy algo (in other case, obviously, start p,q,s).
however, if goal arrange points sum of paired distances smallest, should choose approximate solution travelling salesman problem. note this trick in order reduce task tsp.
Comments
Post a Comment