Calculate the maximum distance between vectors in an array

Suppose we have an array containing n vectors. We want to calculate the maximum Euclidean distance between these vectors. The simplest (naive?) Approach would be to iterate through the array and for each vector calculate its distance with all subsequent vectors, and then find the maximum. However, this algorithm will grow (n-1)! in relation to the size of the array.

Is there an even more effective approach to this problem?

Thanks.

+3
source share
4 answers

, O(n(n-1)/2), O(n^2). O(k), k - ; O(n!).

+2

- O (N ^ 2 * K) (K - ). , , A, B C:

|AB| + |AC| >= |BC|

:

, , MAX, a |AB| C, , |AC| |CB| MAX > |AC|+|CB|, |AB|.

, , O(N*log(N)*K)

+1

, , A B. , A B . C, , A, B?

Further suppose that the partition of points into sqrt (N) is a hyperbox with points sqrt (N) each. For any pair of hyperboxes, we can calculate in k time the maximum distance between any two points in an infinite number of points contained in them - simply by calculating the distance between their farthest corners. If we already have a candidate better than this, we can drop all pairs of points from these hyperboxes.

0
source

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


All Articles