Finding the farthest point in one set from another set

前端 未结 6 1722
旧巷少年郎
旧巷少年郎 2021-02-06 12:05

My goal is a more efficient implementation of the algorithm posed in this question.

Consider two sets of points (in N-space. 3-space for the example case of RGB colorsp

6条回答
  •  逝去的感伤
    2021-02-06 12:14

    The most obvious approach seems to me to be to build a tree structure on one set to allow you to search it relatively quickly. A kd-tree or similar would probably be appropriate for that.

    Having done that, you walk over all the points in the other set and use the tree to find their nearest neighbour in the first set, keeping track of the maximum as you go.

    It's nlog(n) to build the tree, and log(n) for one search so the whole thing should run in nlog(n).

提交回复
热议问题