Example, if i have certain geographic points in an array A=[a,b,c,d...n] and have 10 points distributed in the solution space B= [1,2,3...10], how can I allocate each member of A to the nearest point in B in the quickest way.
What is the quickest way to allocate a set of points to a fixed number groups based on Euclidean distances from a point in each group?
algorithms;code generation
This looks very much like the Nearest neighbor problem. The asymptotically most efficient approach is probably computing a k-d-tree on the points in B. Constructing the tree takes $O(|B| \log |B|)$ and lookup is logarithmic, so an additional $O(|A| \log |A|)$ to find all nearest neighbours.Please not that the constant factors for the naive approach where you just compute the distance to each point in B and take the minimum are really good. CPUs are very good at just summing squared differences. In practice it will be hard to beat that unless B is really huge.