millions of 3d points how to 10 closest to origin

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 5:51 UTC
Read the original article Hit count: 404

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