Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a purely functional data structure for fast nearest neighbor search on n-dimensional space?

I'm looking for a purely functional data structure with an API such as:

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 variation of that, providing fast insertion, removal and query for the nearest element in an n-dimensional space. What is that data-structure?

like image 217
MaiaVictor Avatar asked Sep 18 '15 15:09

MaiaVictor


2 Answers

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

like image 192
Daniel Wagner Avatar answered Sep 23 '22 12:09

Daniel Wagner


For an n-dimensional space, there is also the k-d tree.

like image 28
Andreas Avatar answered Sep 26 '22 12:09

Andreas