r/programminghelp • u/_-random-_-person-_ • May 10 '24
Java K-D trees
Hi everyone. I have made an implementation of a K-D tree in java and I was testing the speed of the nearest neighbor search compared to just brute forcing a solution. I noticed that when using a 10D tree the nearest neighbor search is slower than the brute force solution. Significantly slower. Although in lower dimensions like 2-5 the tree is significantly faster. Is this normal or have I made a mistake during the implementation? Also if you have any examples of how to implement nearest neighbor search in a k-d tree in java that would be great.
View all comments
Show parent comment
2
u/ConstructedNewt MOD May 11 '24
AFAI can see the implementational details look a lot like what I can see others have done. Try running the tests using jfr and see where the highest cost is. You should maybe ask your professor what type of performance and number of dimensions to expect.