What is a purely functional data structure for quickly finding the nearest neighbor in n-dimensional space?

I am looking for a purely functional data structure with an API, for example:

insert :: Vector n Int -> Struct n -> Struct n remove :: Vector n Int -> Struct n -> Struct n nearest :: Vector n Int -> Struct n -> Vector n Int 

Or some variants of this, providing quick insertion, deletion and query for the nearest element in n-dimensional space. What is this data structure?

+6
source share
2 answers

There is a natural generalization of quadtrees from two dimensions to n.

+4
source

For n-dimensional space, there is also kd tree .

+3
source

All Articles