wu :: forums
« wu :: forums - distance of points »

Welcome, Guest. Please Login or Register.
May 16th, 2024, 10:16pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Icarus, towr, Grimbal, ThudnBlunder, SMQ, Eigenray, william wu)
   distance of points
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: distance of points  (Read 598 times)
birbal
Full Member
***





   


Gender: male
Posts: 250
distance of points  
« on: Dec 24th, 2009, 9:34am »
Quote Quote Modify Modify

Given n points on a 2D coordinate system . What is the most efficient way of finding nearest point for each point?  How can we find all the points at a distance k from a given point efficiently? Also does the method followed will depend on the density of points ?
IP Logged

The only thing we have to fear is fear itself!
inexorable
Full Member
***





   


Posts: 211
Re: distance of points  
« Reply #1 on: Jan 2nd, 2010, 11:12am »
Quote Quote Modify Modify

Plane sweep algorithm can be used to find the nearest point to each point in O(nlogn).
 
For a given specific point you can do a plane sweep from X-K coordinate to X+K coordinate to find all points  within K distance.
 
If many queries, for all points within k distance are expected. then preprocessing can be done by constructing n-ary tree with each node representing a square on plane with all points present in it.
IP Logged
abhijeet
Newbie
*





   


Gender: male
Posts: 3
Re: distance of points  
« Reply #2 on: Jan 7th, 2010, 1:17am »
Quote Quote Modify Modify

You can also use KD Trees for this
 
en.wikipedia.org/wiki/Kd-tree
IP Logged
Hippo
Uberpuzzler
*****





   


Gender: male
Posts: 919
Re: distance of points  
« Reply #3 on: Jan 7th, 2010, 1:31am »
Quote Quote Modify Modify

I would construct Voronoi diagram/Delaunay triangulation at first (in O(n log n)). The triangulation has O(n) edges so leaving only minimal directed one going from a vertex neads an additional O(n) time.
 
on Jan 8th, 2010, 3:36am, birbal wrote:
@hippo
can you please explain Voronoi Diagram and how to make it ?

 
Google will ... line sweep algorithm.
 
one of the first hits ...  http://www.diku.dk/hjemmesider/studerende/duff/Fortune/
« Last Edit: Jan 9th, 2010, 5:45pm by Hippo » IP Logged
birbal
Full Member
***





   


Gender: male
Posts: 250
Re: distance of points  
« Reply #4 on: Jan 8th, 2010, 3:36am »
Quote Quote Modify Modify

@hippo
can you please explain Voronoi Diagram and how to make it ?
IP Logged

The only thing we have to fear is fear itself!
baba
Newbie
*





   


Gender: male
Posts: 14
Re: distance of points  
« Reply #5 on: Feb 7th, 2010, 11:31am »
Quote Quote Modify Modify

Isn't this similar to the Top K selection from N given items. Can't we apply Selection Algorithm to get the k nearest point in O(n). Undecided
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board