How does the KD-tree nearest neighbor search work?

后端 未结 3 476
悲&欢浪女
悲&欢浪女 2021-02-02 14:34

I am looking at the Wikipedia page for KD trees. As an example, I implemented, in python, the algorithm for building a kd tree listed.

The algorithm for doing KNN sea

3条回答
  •  别那么骄傲
    2021-02-02 15:01

    lets consider a example,for simplicity consider d=2 and the result of the Kd tree is show below

    Your query point is Q and you want to find out k-nearest neighbours

    The above tree is represents of kd-tree
    we will search through the tree to fall into one of the regions.In kd-tree each region is represented by a single point.

    then we will find out the distance between this point and query point

    Then we will draw a circle with radius of that distance to ensure whether is there any point which are nearer to the query point.

    Then axis which are fall in that circle area,we backtrack to those axis and find near point

提交回复
热议问题