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. CString 的一些事

    MFC Visual Studio 2008 CString 的 Format 中不能这样存在str.Format(_T("Cool(\%)"));  或者 str.Format( ...

  2. juicer模板引擎使用

    http://www.juicer.name/ <script src="~/Scripts/jquery-1.8.2.min.js"></script> ...

  3. HDU 1576 A/B(数论)

    题目:求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1).数据给出n和b 推导过程 A/B = K K = 9973* ...

  4. 自定义一个searchBar

    #import "CZSearchBar.h" @implementation CZSearchBar - (instancetype)initWithFrame:(CGRect) ...

  5. runtime的基本应用

    1.什么是runtime? runtime是一套底层的C语言API,包含很多强大实用的C语言数据类型和C语言函数,平时我们编写的OC代码,底层都是基于runtime实现的. 2.runtime有什么作 ...

  6. iOS之Swift语言的学习

    好久都没有来这个熟悉而又陌生的地方啦, 想想已经有两三个月了吧,不过我相信以后还是会经常来的啦,因为忙碌的学习已经过去啦,剩下的就是要好好的总结好好的复习了,好好的熟悉下我们之前学习的知识点,将他们有 ...

  7. oracle数据库recover和restore的区别

    restore just copy the physical file, recover will consistent the database.restore 是还原,文件级的恢复.就是物理文件还 ...

  8. 怎么使用jQuery在DIV适应屏幕大小一直居中

    js的代码是这样的: $(function(){ $(window).resize(function(){ $(".login").css({ position: "ab ...

  9. 一个很经典的this面试题

    !function(){ this.length = 10; var fn = function(){ console.log(this.length); //输出多少? }, arr = [fn, ...

  10. baidu地图的一个拾取坐标系统

    http://api.map.baidu.com/lbsapi/getpoint/index.html 可以很方便的通过标记取得经纬度坐标 也可以输入经纬度坐标获得地图标记