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的更多相关文章

  1. 第46届ICPC澳门站 K - Link-Cut Tree // 贪心 + 并查集 + DFS

    原题链接:K-Link-Cut Tree_第46屆ICPC 東亞洲區域賽(澳門)(正式賽) (nowcoder.com) 题意: 要求一个边权值总和最小的环,并从小到大输出边权值(2的次幂):若不存在 ...

  2. AOJ DSL_2_C Range Search (kD Tree)

    Range Search (kD Tree) The range search problem consists of a set of attributed records S to determi ...

  3. Size Balance Tree(SBT模板整理)

    /* * tree[x].left 表示以 x 为节点的左儿子 * tree[x].right 表示以 x 为节点的右儿子 * tree[x].size 表示以 x 为根的节点的个数(大小) */ s ...

  4. HDU3333 Turing Tree(线段树)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=3333 Description After inventing Turing Tree, 3x ...

  5. K-D Tree

    这篇随笔是对Wikipedia上k-d tree词条的摘录, 我认为解释得相当生动详细, 是一篇不可多得的好文. Overview A \(k\)-d tree (short for \(k\)-di ...

  6. POJ 3321 Apple Tree(树状数组)

                                                              Apple Tree Time Limit: 2000MS   Memory Lim ...

  7. CF 161D Distance in Tree 树形DP

    一棵树,边长都是1,问这棵树有多少点对的距离刚好为k 令tree(i)表示以i为根的子树 dp[i][j][1]:在tree(i)中,经过节点i,长度为j,其中一个端点为i的路径的个数dp[i][j] ...

  8. Segment Tree 扫描线 分类: ACM TYPE 2014-08-29 13:08 89人阅读 评论(0) 收藏

    #include<iostream> #include<cstdio> #include<algorithm> #define Max 1005 using nam ...

  9. Size Balanced Tree(SBT) 模板

    首先是从二叉搜索树开始,一棵二叉搜索树的定义是: 1.这是一棵二叉树: 2.令x为二叉树中某个结点上表示的值,那么其左子树上所有结点的值都要不大于x,其右子树上所有结点的值都要不小于x. 由二叉搜索树 ...

随机推荐

  1. php 站内搜索 多表 分页

    借鉴了:http://blog.chinaunix.net/uid-20787846-id-3488253.html 这篇文章 ,在此基础上增加了分页功能 <?php /* 关键字 */ $ke ...

  2. Redis + Jedis + Spring 实例(对象的操作)

        目录(?)[+] 不得不说,用哈希操作来存对象,有点自讨苦吃! 不过,既然吃了苦,也做个记录,也许以后API升级后,能好用些呢?! 或许,是我的理解不对,没有真正的理解哈希表. 一.预期 接上 ...

  3. HDU 1827 Summer Holiday(Tarjan缩点)

    Problem Description To see a World in a Grain of Sand  And a Heaven in a Wild Flower,  Hold Infinity ...

  4. [Unit Testing] Directive testing, require parent controller

    function getCompiledElement() { $scope.chart = { additional: "$ 1.56 / per minute", text: ...

  5. BOOST 线程完全攻略 - 扩展 - 事务线程

    扩展threadtimermoduleexceptionsocket 什么叫事务线程 举个例子: 我们写一个IM客户端的登录子线程,则该子线程会有这么几个事务要处理 No.1 TCP Socket物理 ...

  6. zabbix PHP databases support off Fail

    zabbix初始化检查安装环境不通过: PHP databases support off   Fail     --未找到所支持的数据库 处理方法:安装Mysqli模块 ############## ...

  7. C# 类属性封装、字段的详解

    今日敲代码时,突然感觉对类的属性封装.字段有点犯迷糊了..连基础的都不知道了,那敲的代码怎么能严谨高效的.果断拿起各种高级编程.大全啥的翻起来~~这不再把自己的理解写下来(定义都是直接抄书的),献给同 ...

  8. 读《疯狂Ajax讲义》重点

    1.XMLHttpRequest() 请求的写法(p62) 一个类XMLHttp 因该包含的接口:[1]  XMLHttp.sendRequest("POST",URL,data, ...

  9. 飘逸的python - 多条件排序及itemgetter的应用

    曾经客户端的同事用as写一大堆代码来排序,在得知python排序往往只需要一行,惊讶无比,遂对python产生浓厚的兴趣. 之前在做足球的积分榜的时候需要用到多条件排序,如果积分相同,则按净胜球,再相 ...

  10. JSON序列化选项

    JSON.stringify()除了接受序列化js对象外,还可以接受另外的两个参数,这两个参数用于指定使用什么样的方式序列化js对象. 第一个参数是个过滤器,可以一个数组或者一个函数:第二个参数是一个 ...