r/AskProgramming • u/puremath369 • Apr 11 '19
How does Tinder and Bumble implement nearest neighbors?
I'm looking for a data structure that would allow for efficient look ups of points within a certain radius from another point. That is, given a certain point and a radius, return all points within that radius to the given point. Basically, how does tinder and bumble accomplish this when you find other people X miles from me? I've heard of the K nearest neighbors algorithm but, this is hard because how do I appropriately select K? For example, suppose I select K = 1000 but in reality, k = 5000 would've return results all still within X miles from me. Anyone know of any data structures that can accomplish this efficient searching? It's okay if insertion of the data is not as efficient since searching will be used much more.
1
u/eFrazes Apr 12 '19
I did this along time ago to map zip codes within range of a given lat/lon. My brother the math whiz wrote a formula with trig functions.
Now days you can use a google api to do the same thing without all the math.