码迷,mamicode.com
首页 > 其他好文 > 详细

k-d Tree in TripAdvisor

时间:2015-10-10 06:47:47      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

Today, TripAdvisor held a tech talk in Columbia University. The topic is about 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 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 that axis cycles through all valid 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

标签:

原文地址:http://www.cnblogs.com/ireneyanglan/p/4865641.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!