algorithm - Java grouping point which can fall in a rectangle -
I am doing a research where I am stuck in solving an algorithm efficiently. If someone helps me then I will really be useful in this -
algo -
I have a set of digits (x1, y1), (x2, y2). .. (can be 10000 digits). I would like to print points in a group - which can be attached to the rectangle of 10x10.
Examples -
(10,10) P2) P7 (400,350) Output GP1 - & gt; P1 (10,10), P2 (1515) GP2 - & gt; P3 (40,100), p5 (40,90)
Explanation - point P1 and P2 will fall into a rectangle if the point P1 to 10x10 is rectangular. Similar P3 & amp; P5 will fall into a rectangle of 10x10 if the rectangular point will start from p3. It will also be helpful if we can coordinate to attach each rectangle.
Note: A single point can be related to 2 different groups. In this case, everyone will get a group and then the size of the rectangle will increase.
What I tried -
I tried to coordinate point P1 and its X & A With others, if I got Point P2 near it I add them to a group and then bypassing others, I leave P2, I start the process again with P3.
It does not seem to be an efficient solution as it may be the worst case scenario with NXN complexity which is very bad.
Note: I do not consider all to you as a homework because it is not.
To get any kind of proper performance out of a clustering problem, There is a need to organize which fits your algorithmic requirements first. The problem you are trying to solve may be suitable for "KD Tree"
Once you have arranged your data in a KD tree, you can The distance between different nodes can ask questions more efficiently about relationships.
Here is a stack overflow question about the Java implementation of a KD tree.
Comments
Post a Comment