0

Input:

  • A 2-dimentional space of size MxN .

  • K points(integer pair) in this 2 dim space.

Output:

A point xj, yj from set of K points such that dist(i,j) in minimum where xi, yi is the current point.

dist(i,j) : is root mean square distance

Given K << M*N, K~M, K~N, M~N

Expected time complexity:

  • O(M*N) for each query is definitely not enough.
  • O(K) for each query is also not enough.
  • Anything better than this will be acceptable.
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129
  • 1
    "A point xj, yj" seems to imply we are dealing with a two dimensional space. Then you may want to have a look at Voronoi diagrams. Or this: https://en.wikipedia.org/wiki/Nearest_neighbor_search – Henry Dec 01 '18 at 07:38
  • yes you are right. reworded the problem for clarity. – ishandutta2007 Dec 01 '18 at 07:40
  • Are the coordinates integers or real numbers? – Henry Dec 01 '18 at 07:44
  • they are inegers, modified question – ishandutta2007 Dec 01 '18 at 07:45
  • I can think of a 2-D segment tree approach, let me know if you have some innovative thoughts. Each query will take O(M*logM*LogN) or vice versa depending on whichever between M,N is smaller. – ishandutta2007 Dec 01 '18 at 07:47
  • There are only finitely many query points possible. You could pre-compute the closest point for each of them. This gives an O(1) query time. Are there any time bounds on the pre-computation? – Henry Dec 01 '18 at 07:50
  • I have K queries, each query say if it takes O(K) in worst case without much heavy precomputation, then overall time is k*k . So with heavy precomputation , the precoputation time should be lesser than this to beat the overall time. Any thing better than k^2 overall(ie for all queries) is acceptable. – ishandutta2007 Dec 01 '18 at 07:54

0 Answers0