B + trees and B- trees

concept

B- tree, also known as B-tree is more than one balanced search trees. When describing a B-tree, it needs to specify the order m, the number of children up to m represents the number of nodes in the child node. When m is 2, B- Tree is a binary search tree.

definition:

  1) the root node has at least one keyword;

  2) non-root nodes with at least m / 2-1 keywords;

  3) Each node has at most m-1 keyword;

  4) all the leaf nodes are at the same level;

  5) key of each node in sequence, each of the left subtree keyword than the keyword of keyword small, right subtree are larger than the keyword.

FIG 4 is a B-stage tree. B-tree each node stores a key (key) corresponding to the value (value). In the B-tree database we (and B + tree) as the index structure,

Can speed up queries swift, this time on the key tree B represents a bond, and the value represents the logical address entries corresponding to the key on the hard disk.

 

 

B + Tree

definition:

  1) B + tree contains two types of nodes: internal node and leaf nodes, the root node can either be an internal node may be a leaf, root least contains a keyword;

  2) The number of internal node key points in children less than 1 section, the internal node is limited to m-1 keyword, which leaf nodes also comprise up to m-1 keyword;

  3) B + tree nodes are not stored internal data, the data is stored in the leaf node;

  Keyword 4) internal nodes in ascending order of sorts, a key left subtree of all keywords than small that keyword, all the keywords in the right subtree are larger than the keyword;

  5) there are leaf node pointer neighboring node, the leaf node sequentially connected.

B + trees and B- trees similarities and differences:

The difference between the following two points:

  . 1) B + non-leaf nodes of the tree does not store data, and a non-leaf tree storing data B-, B + tree leaf nodes store data;

  2) B + tree leaf nodes all connected together by a pointer;

B + Tree advantages:

  1) connected to the leaf node pointer, to facilitate the scanning range, and will need to move back and forth between the internal node and a leaf node when performing the B- tree scan range;

   2) B + tree every scan starting from the root end to the leaf node, and thus more stable.

B- Tree advantages:

  For internal node data can be obtained directly, through access to a few leaves.

 B- tree node insertion step:

  1) First, by keyword search to the node you want to insert keywords.

  2) is inserted into the node key, and sorting, determining whether the node key number is greater than m-1, if greater than keywords from the intermediate division, the insert key intermediate position to the parent node, the parent the new node pointer points to the new node splitting, or directly into.

Guess you like

Origin www.cnblogs.com/menbo/p/11028214.html