Today, TripAdvisor held a tech talk in Columbia University. The topic is on k-d tree implemented in TripAdvisor to efficiently search MASSIVE location Tree.
Problem
Millions of locations, it ' s tough to perform Nearest Neighbor Search.
Solution
Using k-d tree to implement the location tree.
It ' s a space-partitioning balanced binary tree. and K is the number of dimension.
K-d Tree
Pseudocode
function Kdtree (List of points pointlist, int depth) { //Select axis based on depth so the axis cycles through all V Alid values var int axis: = depth mod k; Sort point list and choose Median as pivot element Select median by axis from Pointlist; Create node and construct subtrees var tree_node node; Node.location: = median; Node.leftchild: = Kdtree (points in pointlist before median, depth+1); Node.rightchild: = Kdtree (points in pointlist after median, depth+1); return node;}
K-d Tree in TripAdvisor