Re: Closest Point Problem
From: Ash (amujoo_at_yahoo.com)
Date: 09/09/04
- Previous message: Simon G Best: "Re: [PO] Halting Problem Final Conclusion"
- In reply to: Howard: "Re: Closest Point Problem"
- Next in thread: Marc Goodman: "Re: Closest Point Problem"
- Reply: Marc Goodman: "Re: Closest Point Problem"
- Reply: newstome_at_comcast.net: "Re: Closest Point Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Sep 2004 23:25:43 -0700
"Howard" <alicebt@hotmail.com> wrote in message news:<lFL%c.568582$Gx4.373652@bgtnsc04-news.ops.worldnet.att.net>...
> "Ash" <amujoo@yahoo.com> wrote in message
> news:60aab6b4.0409072328.63b1b627@posting.google.com...
> > Given N points in space, what is the best possible algorithm to find k
> > points closest to origin? What is the time complexity of the
> > algorithm.
> >
> > Any solutions?
> >
> > Thanks
> > ASH
>
> Computing time complexity was never my strong point, but how about this
> method:
>
> Use a binary tree to store the smallest k numbers. Larger numbers go right,
> smaller go left at any given node in the tree. That way, you can go right
> from the root to find the point with the largest distance (of the k so far
> stored) in, what, log k steps? Keep track of the size of the tree (in
> number of points stored). When computing a new distance, see if the size is
> k or greater. If it is, then find the node with the largest distance (by
> going right until you can't go right any more - order log k, right?), and
> delete that node (re-attaching its left child, if needed, to the parent of
> that node or as a new root node, as appropriate). Then insert the new node
> by traversing the tree to find its correct location (again, order log k,
> right?). (Increment the size if it wasn't already at k.) When you're done
> all the points, the tree holds the closest k, and a traversal of the tree
> can give you those in order, if you like.
>
> So what is that complexity? O(n * (log k + log k))? Which would be O(2n
> log k)? (Like I said, I suck at those computations! :-))
>
> -Howard
I see that everybody is trying to convert the problem into a sorting
or finding k smallest problem. May be that is the way of solving this,
but I wonder if the "points in space" carries any significance. The
coordinates given (x,y,z) for each point, do they hold any hint for
the solution?
- Ash
- Previous message: Simon G Best: "Re: [PO] Halting Problem Final Conclusion"
- In reply to: Howard: "Re: Closest Point Problem"
- Next in thread: Marc Goodman: "Re: Closest Point Problem"
- Reply: Marc Goodman: "Re: Closest Point Problem"
- Reply: newstome_at_comcast.net: "Re: Closest Point Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|