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. 利用sql 存储过程把表中内容自动生成insert语句

    选中所在数据库 执行创建存储过程的sql CREATE proc [dbo].[spGenInsertSQL] (@tablename nvarchar(256),@sqlwhere varchar( ...

  2. soj 1700 ping_简单dp

    题目链接 题意:给你一个无向图,求n边的最短路 思路:用最短路想了半天都没想出来,比赛结束回去看看原来用dp做,我的dp有待提高啊 sp[i][k]=min(sp[j][k-1]+dp[j][i])/ ...

  3. 直接使用ip访问google搜索

    173.194.127.148 173.194.127.51 173.194.36.48 (亲测,个人在用,有的ip有时候应该不能访问); 173.194.72.101 173.194.72.103 ...

  4. <转载>Wait and Waitpid

    转载http://www.cnblogs.com/lihaosky/articles/1673341.html 一.Wait #include <sys/types.h> /* 提供类型p ...

  5. 构建高性能web站点笔记一

    构建高性能web站点笔记 第三章 服务器并发处理能力 3.1吞吐率 描述服务器在实际运行期间单位时间内处理的请求数.也就是一定并发用户的情况下,服务器处理请求能力的量化体现. 吞吐率的前提包括: 并发 ...

  6. vmware虚拟机迁移系统到其它磁盘(xjl456852原创)

    有时我们将vmware安装的系统放在了磁盘空间比较小的盘里,后来磁盘空间不够用了,我们需要将文件移动到其它磁盘.腾出这个磁盘的空间. 我安装的系统有10个,总占空间大小170多GB.需要从D盘迁移到G ...

  7. python之路-模块 splinter

    Splinter介绍 Splinter is an open source tool for testing web applications using Python. It lets you au ...

  8. How to uninstall (remove) JAVA from OS X Lion

    Open terminal (Applications -> Utilities -> Terminal) To remove JVM enter folowing: sudo rm -r ...

  9. linux下修改防火墙端口对外开放方法

    ---linix CentOS7的防火墙换成了firewall了,这里做一些记录,下面是一些命令:添加例外端口:# firewall-cmd --add-port=8080/tcp删除例外端口:# f ...

  10. UVa 10256 The Great Divide,推断两个凸包是否相离

    先从给出的两个点集中分别计算出两个凸包, 然后推断两个凸包是否相离. #include<cstdio> #include<vector> #include<cmath&g ...