Skip to main content
added 38 characters in body
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56

Complexity is O(N^3N^2 * K) for brute force algorithm (K is number of elem in vector). But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AC|+|CB|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N)*K)

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AC|+|CB|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

Complexity is O(N^2 * K) for brute force algorithm (K is number of elem in vector). But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AC|+|CB|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N)*K)

edited body
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AB|+|AC||AC|+|CB|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AB|+|AC|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AC|+|CB|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

added 1 characters in body
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and we know distances for a AB|AB| there is a point C, such that distance |AC| and AC|CB| already computed and MAX > (AB+AC)|AB|+|AC|, then we can skip calculation for BC|AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and we know distances for AB and AC and MAX > (AB+AC), then we can skip calculation for BC.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

Complexity is O(N^3) for brute force algorithm. But we can do better by knowing that in euclidean space for points A,B and C:

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

Algorithm should be something like this:

If max distance found so far is MAX and for a |AB| there is a point C, such that distance |AC| and |CB| already computed and MAX > |AB|+|AC|, then we can skip calculation for |AB|.

It is difficult to tell complexity of this algorithm, but my gut feeling tells me it is not far from O(N*log(N))

added 1 characters in body
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56
Loading
added 119 characters in body
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56
Loading
Source Link
Leonid Volnitsky
  • 9.2k
  • 5
  • 41
  • 56
Loading