-1

Hi ive done some researchs in this forum and didnt really find a prpoer answer to my problem. I need to solve , with the fastest algorithm possible a financial problem. Given p set of points , each set have n points , i need to find the algorithm wich will calculate all the closest points between every set of points. I think it can be done with the closest pair algo or the nearest neighbour but i dont see how can i make it in less than o(n^2) operations.

  • 2
    Hello and welcome to stackoverflow.com. Please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist). You might also want to learn what a [SSCCE](http://sscce.org/) is. – Some programmer dude Nov 07 '13 at 10:49
  • What do you mean by "all the closest points between every set of points"? – S. Huber Oct 31 '17 at 22:08

2 Answers2

0

If this is a code question, at least give some code. if it is a mathematical question there is a division made just for mathematics.

Hakeem El Bakka-lee
  • 756
  • 1
  • 7
  • 23
0

So, there are a few acceleration structures that you could use to get faster lookups. You could create a K-d tree for each set. That would mean that each lookup would take O(log(n)), so the total for all lookups would be O(n log(n)).

The creation of the k-d trees would take O(n log(n)) by itself. Adding those together you still get O(n log(n)).

However, in most real-world cases, the O isn't the only thing to consider - the scalar factors are also very important. K-d trees are pretty straightforward to implement. Depending on the shape of your data (whether you have a lot of overlaps), you might be able to find some more speed using a different acceleration structure.

tfinniga
  • 6,693
  • 3
  • 32
  • 37