B-tree

  • B-tree is a tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time.

    • B-trees are balanced search trees: height for the worst case, where t >2 is the order of tree, i.e., the maximum number of pointers for each node.
    • Note that t is typically set so that one node fits into one disk block or page.
  • B-tree is a generalization of a binary search tree (i.e., a multiway tree) in that a node can have more than two children. 
    • Similar to red-black trees, but show better performance on disk I/O operations.
    • Binary trees may be useful for rapid searching in main memory, but not appropriate for data stored on disks.
    • When accessing data on a disk, an entire block (or page) is input at once, so it makes sense to design the tree so that each node essentially occupies one entire block. 

  • B-tree is optimized for systems that read and write large blocks of data. B-trees (and its variants) are commonly used in databases and file systems.
  • Structure: every node x has four fields
    1. The number of keys currently stored in node x, i.e., n, which is between [t/2]-1 and t-1.
    2. The n keys themselves, stored in non-decreasing order:
    3. A boolean value
    4. n+1 pointers:  to its children, represented by: 
  • Properties:
    • All leaves have the same height, which is the tree's height h.
    • B-tree guarantees a storage utilization of at least 50%, i.e., at least half of each allocated page actually stores index entries.
    • There are upper and lower bounds on the number of keys on a node. 
      • Lower bound: every node other than root must have at least t-1 keys => at least t children
      • Upper bound: every node can contain at most 2t-1 keys => every internal node has at most 2t children.
      • Example is shown as follows: 


  • Conventions:
    • Root of B-tree is always in main memory
    • Any node pased as parameter must have had a Disk-Read operation performed on them.

B+-tree

  • A B-tree is very efficient with respect to search and modification operations that involve a single record.
  • But it is not particularly suited for sequential operations nor for range searches, B+-tree is to solve this issue.
  • B+-tree is the most widely used index structure for databases.
  • Main idea:
    • The leaf nodes contain all the key values (and the associated information)
    • The internal nodes (organized as a B-tree) store some separators which have the only function of determining the path to follow during searching
    • The leaf nodes are linked in a (doubly linked) list, in order to efficiently support range searches or sequential searches.


  • Comparison with B-trees:
    • The search of a single key value is in general more expensive in a B+-tree because we have always to reach a leaf node to fetch the pointer to the data file.
    • For operations requiring an ordering of the retrieved records according to the search key values or for range queries, the B+-tree is to be preferred.
    • The B-tree requires less storage since the key values are stored only once.

B*-tree

  • B*-tree is a variation of the B+-tree where the storage utilization for nodes must be at least 66% (2/3) instead of 50%.
  • The non-root and non-leaf nodes of B*-tree contain pointers to sibling nodes.

R-tree

  • The B-tree and its variants are useful to index and search data in one-dimensional space (where data is stored on disks rather than main memory). The basic idea is to separate a line into several segments and gradually reduce to the minimum segment where the searched data is located, illustrated as follows (figure is obtained from July et al.'s blog):

  • However, for high-dimensional data, B-tree and its variants are not efficient. Other tree index structures such as R-tree, kd-tree are more suited in this case.
  • R-tree is a generalization of B-tree for indexing and searching multi-dimensional data such as geographical coordinates, rectangles or polygons.
  • A commonly real-world usage for an R-tree might be to store spatial objects such as restaurant locations, or the polygons that typical maps are made of scuh as streets, buildings, outlines of lakes, coastlines, etc, and then find answers quickly to queries such as "Find all museums within 2km of my current location". => It is useful for map.
  • Main points: 
    • The key idea is to group nearby objects and represent them with their minimum bounding rectangle in the next higher level of the tree.
    • At the leaf level, each rectangle describes a single object; at higher levels, the aggregation of an increasing number of objects.
    • R-tree is a balanced search tree (i.e., all leaf nodes are at the same height), organizes the data in pages, and is designed for storage on disk (as used in databases).
    • R-tree only guarantees a minimum usage of 30-40%. The reason is the more complex balancing required for spatial data as opposed to linear data stored in B-trees.
    • The key difficulty of R-tree is to build an efficient tree that on one hand is balanced, on the other hand the rectangles do not cover too much empty space and do not overlap too much.
    • A typical R-tree is represented as follows (figure is originally from Wikipedia). 


References

Study notes for B-tree and R-tree的更多相关文章

  1. SQLite R*Tree 模块测试

    目录 SQLite R*Tree 模块测试 1.SQLite R*Tree 模块特性简介 2.SQLite R*Tree 模块简单测试代码 SQLite R*Tree 模块测试 相关参考: MySQL ...

  2. Machine Learning Algorithms Study Notes(2)--Supervised Learning

    Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...

  3. Machine Learning Algorithms Study Notes(3)--Learning Theory

    Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...

  4. Machine Learning Algorithms Study Notes(1)--Introduction

    Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 目 录 1    Introduction    1 1.1    ...

  5. B-Tree、B+Tree和B*Tree

    B-Tree(这儿可不是减号,就是常规意义的BTree) 是一种多路搜索树: 1.定义任意非叶子结点最多只有M个儿子:且M>2: 2.根结点的儿子数为[2, M]: 3.除根结点以外的非叶子结点 ...

  6. 【Luogu1501】Tree(Link-Cut Tree)

    [Luogu1501]Tree(Link-Cut Tree) 题面 洛谷 题解 \(LCT\)版子题 看到了顺手敲一下而已 注意一下,别乘爆了 #include<iostream> #in ...

  7. 【BZOJ3282】Tree (Link-Cut Tree)

    [BZOJ3282]Tree (Link-Cut Tree) 题面 BZOJ权限题呀,良心luogu上有 题解 Link-Cut Tree班子提 最近因为NOIP考炸了 学科也炸了 时间显然没有 以后 ...

  8. [LeetCode] Encode N-ary Tree to Binary Tree 将N叉树编码为二叉树

    Design an algorithm to encode an N-ary tree into a binary tree and decode the binary tree to get the ...

  9. 平衡二叉树(Balanced Binary Tree 或 Height-Balanced Tree)又称AVL树

    平衡二叉树(Balanced Binary Tree 或 Height-Balanced Tree)又称AVL树 (a)和(b)都是排序二叉树,但是查找(b)的93节点就需要查找6次,查找(a)的93 ...

  10. WPF中的Visual Tree和Logical Tree与路由事件

    1.Visual Tree和Logical TreeLogical Tree:逻辑树,WPF中用户界面有一个对象树构建而成,这棵树叫做逻辑树,元素的声明分层结构形成了所谓的逻辑树!!Visual Tr ...

随机推荐

  1. PDF417码

    PDF417码是由留美华人王寅敬(音)博士发明的.PDF是取英文Portable Data File三个单词的首字母的缩写,意为“便携数据文件”.因为组成条码的每一符号字符都是由4个条和4个空构成,如 ...

  2. mysql merge table

    SELECT COUNT(*) FROM `comment` SHOW CREATE TABLE `comment` CREATE TABLE `comment1` ( `id` INT(8) NOT ...

  3. Drainage Ditches(最大流)

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64044   Accepted: 2471 ...

  4. SQL 表连接,内联、外联、全连

    内连接,join 或 inner join 两个表中符合条件的集合 外连接,left join  或  right  join 以left左边或right右边的表为数据集合行,根据条件,另一侧没有的数 ...

  5. COM组件

    COM组件   COM component(COM组件)是微软公司为了计算机工业的软件生产更加符合人类的行为方式开发的一种新的软件开发技术.在COM构架下,人们可以开发出各种各样的功能专一的组件,然后 ...

  6. Centos6.4下tar包安装最新版Mysql5.6

    1.下载 mysql:http://www.mysql.com/downloads/ (须要注冊ORACLE账号) 版本号:mysql-advanced-5.6.21-linux-glibc2.5-x ...

  7. Android 启动APP时黑屏白屏的三个解决方案(转载)

    你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单 ...

  8. iOS 开发http post 文件的上传

    iOS开发网络篇—文件的上传 说明:文件上传使用的时POST请求,通常把要上传的数据保存在请求体中.本文介绍如何不借助第三方框架实现iOS开发中得文件上传. 由于过程较为复杂,因此本文只贴出部分关键代 ...

  9. javascript复制

    1.实现点击按钮,复制文本框中的的内容 1 <scrip type="text/javascript"> 2 function copyUrl2() 3 { 4 var ...

  10. OKR 方法 学习笔记

    最近公司兴起了对OKR这个词的讨论,并且听到时总会伴随提到KPI,提到绩效考核.那OKR到底是什么呢?与KPI的区别在哪里?与绩效考核有什么关系?它与我们现在推行的敏捷开发有啥关系呢?因此,就到网上查 ...