How to calculate the average time complexity of the nearest neighbor search using kd-tree?

PyChen

We know the complexity of the nearest neighbor search of kd-tree is O(logn). But how to calculate it? The main problem is the average time complexity of the back tracing. I have tried to read the paper "An Algorithm for Finding Best Matches in Logarithmic Expected Time", but it is too complicate for me. Does anyone know a simple way to calculate that?

Gene

The calculation in the paper is about as simple as possible for a rigorous analysis.

(NB This is the price of being a true computer scientist and software engineer. You must put the effort into learning the math. Knowing the math is what separates people who think they can write solid programs from those who actually can. Jon Bentley, the guy who invented kd-trees, did so when he was in high school. Take this as inspiration.)

If you want a rough intuitive idea that is not rigorous, here is one.

Assume we are working in 2d. The sizes of the geometric areas represented by the 2d-tree are the key.

In the average case, one point partitions the domain into 2 roughly equal-sized rectangles. 3 points into 4. 7 points into 8 parts. Etc. In general N points lead to N-1 roughly equal-sized rectangles.

It not hard to see that if the domain is 1x1, the length of a side of these parts is on average O(sqrt(1/N)).

When you search for a nearest neighbor, you descend the tree to the rectangle containing the search point. After doing this, you have used O(log N) effort to find a point within R = O(sqrt(1/N)) of the correct one. This is just a point contained in the leaf that you discovered.

But this rectangle is not the only one that must be searched. You must still look at all others containing a point no more than distance R away from the search point, refining R each time you find a closer point.

Fortunately, the O(sqrt(1/N)) limit on R provides a tight bound on the average number of other rectangles this can be. In the average case, it's about 8 because each equal-sized rectangle has no more than 8 neighbors.

So the total effort to search is O(8 log n) = O(log n).

Again, I repeat this is not a rigorous analysis, but it ought to give you a feel for why the algorithm is O(log N) in the average case.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to calculate the average time complexity of the nearest neighbor search using kd-tree?

From Dev

Using Nearest Neighbor search on an n element object

From Dev

2D KD Tree and Nearest Neighbour Search

From Dev

How to calculate time complexity?

From Dev

How to calculate time complexity?

From Dev

How to efficiently find k nearest neighbours from a kd tree

From Dev

How to calculate average time

From Dev

Algorithm for Octree for nearest neighbor search

From Dev

Unexpected slowdown due to maximum radius in kd-tree nearest neighbour search

From Dev

Unexpected slowdown due to maximum radius in kd-tree nearest neighbour search

From Dev

How to calculate the time complexity of this code?

From Dev

How to calculate time complexity for this algorithm

From Dev

How to calculate time complexity of these functions

From Dev

How to calculate time complexity for this algorithm

From Dev

Running time complexity for binary search tree

From Dev

Time complexity of deletion in binary search tree

From Dev

GATE 2008: Time Complexity of Binary Search Tree

From Dev

Time complexity of deletion in binary search tree

From Dev

Time complexity in search of a list within a tree

From Dev

How to calculate average seek time?

From Dev

How to calculate average interval time

From Dev

How do i calculate space complexity for checking if binary search tree is balanced?

From Dev

How do i calculate space complexity for checking if binary search tree is balanced?

From Dev

How to use Scipy's Kd-tree function to speed up K-Nearest Neighbors (KNN)

From Dev

How to solve nearest neighbor through the R-nearest neighbor?

From Dev

PostGIS Nearest Neighbor Search Results Out of Order?

From Dev

Average Time Complexity

From Dev

How to calculate time complexity of DFS algorithm?

From Dev

how to calculate Bubble sort Time Complexity

Related Related

  1. 1

    How to calculate the average time complexity of the nearest neighbor search using kd-tree?

  2. 2

    Using Nearest Neighbor search on an n element object

  3. 3

    2D KD Tree and Nearest Neighbour Search

  4. 4

    How to calculate time complexity?

  5. 5

    How to calculate time complexity?

  6. 6

    How to efficiently find k nearest neighbours from a kd tree

  7. 7

    How to calculate average time

  8. 8

    Algorithm for Octree for nearest neighbor search

  9. 9

    Unexpected slowdown due to maximum radius in kd-tree nearest neighbour search

  10. 10

    Unexpected slowdown due to maximum radius in kd-tree nearest neighbour search

  11. 11

    How to calculate the time complexity of this code?

  12. 12

    How to calculate time complexity for this algorithm

  13. 13

    How to calculate time complexity of these functions

  14. 14

    How to calculate time complexity for this algorithm

  15. 15

    Running time complexity for binary search tree

  16. 16

    Time complexity of deletion in binary search tree

  17. 17

    GATE 2008: Time Complexity of Binary Search Tree

  18. 18

    Time complexity of deletion in binary search tree

  19. 19

    Time complexity in search of a list within a tree

  20. 20

    How to calculate average seek time?

  21. 21

    How to calculate average interval time

  22. 22

    How do i calculate space complexity for checking if binary search tree is balanced?

  23. 23

    How do i calculate space complexity for checking if binary search tree is balanced?

  24. 24

    How to use Scipy's Kd-tree function to speed up K-Nearest Neighbors (KNN)

  25. 25

    How to solve nearest neighbor through the R-nearest neighbor?

  26. 26

    PostGIS Nearest Neighbor Search Results Out of Order?

  27. 27

    Average Time Complexity

  28. 28

    How to calculate time complexity of DFS algorithm?

  29. 29

    how to calculate Bubble sort Time Complexity

HotTag

Archive