Millions of 3D points: How to find the 10 of them closest to a given point?

Posted by Kazoom on Stack Overflow See other posts from Stack Overflow or by Kazoom
Published on 2010-03-21T05:47:06Z Indexed on 2010/03/21 6:01 UTC
Read the original article Hit count: 418

A point in 3-d is defined by (x,y,z). Distance d between any two points (X,Y,Z) and (x,y,z) is d= Sqrt[(X-x)^2 + (Y-y)^2 + (Z-z)^2]. Now there are a million entries in a file, each entry is some point in space, in no specific order. Given any point (a,b,c) find the nearest 10 points to it. How would you store the million points and how would you retrieve those 10 points from that data structure.

© Stack Overflow or respective owner

Related posts about interview-questions

Related posts about algorithm