geometry - Effiecient algorithm for matching line segments without intersection -
i wanted know efficient algorithm match (partition n/2 distinct pairs) n=2k points in general position in plane in such way segments joining matched points not cross. idea out immmensely.
mr. srkv there simpler way of doing it.
- sort points based on x-coordinate.
- now pair left point next left one.
- remove 2 points paired.
- continue step 2 till there no points left.
in case 2 points have same x-coordinate. following tie breaking rule.
- join point lower y-coordinate point 2nd lowest y-coordinate.
- if there odd number of points same x-coordinate, join lone remaining point (topmost y) next x-coordinate(if multiple lowest one).
total complexity o(nlogn) sort , o(n) traverse asymptotically o(nlogn).
Comments
Post a Comment