| B+ Tree |
Website Links For Tree |
Information AboutB+ Tree |
|
In Computer Science , a B+ tree (also known as a Quarternary Tree) is a type of Tree , which represents sorted data in a way that allows for efficient insertion, retrieval and removal of records, each of which is identified by a ''key''. It is a dynamic, multilevel index, with maximum and minimum bounds on the number of keys in each index segment (usually called a ' Block ' or ' Node '). In a B+ tree, in contrast to a B-tree , all records are stored at the lowest level of the tree; only keys are stored in interior blocks. The primary value of a B+ tree is in storing data for efficient retrieval in a Block-oriented storage context. Given a storage system with a Block Size of , a B+ tree which stores a number of keys equal to a multiple of will be very efficient when compared to a Binary Search Tree (the corresponding data structure for non-block-oriented storage contexts). The NTFS filesystem (for Microsoft Windows ), ReiserFS filesystem (for Unix and Linux ), XFS filesystem (for IRIX and Linux ), and the JFS2 filesystem (for AIX , OS/2 and Linux ) all use this type of tree for block indexing. Relational Databases also often use this type of tree for table indices (in fact, file systems and relational database tables can be thought of as differently Optimised variants on the same idea). DETAILS The maximum number of keys or records that can be stored in a block is called the Order of the B+ tree; the minimum number is of the maximum (if the order is odd, this will be rounded either up or down, consistently throughout the tree). Usually the order is denoted by the variable ''b''. The minimum restriction is lifted for the root index, because the tree may contain too few entries to fully populate this index. For example, if the order of a B+ tree is ''b'', each node (except for the root) may have between and ''b'' keys; the root may have between 2 and ''b''. The number of keys that may be indexed using a B+ tree is a function of the order of the tree and its height. Search The algorithm to perform a search for a record r follows pointers to the correct child of each node until a leaf is reached. Then, the leaf is scanned until the correct record is found (or until failure). function search(record r) u := root while (u is not a leaf) '''do''' choose the correct pointer in the node move to the first node following the pointer u := current node scan u for r This pseudocode assumes that no repetition is allowed. CHARACTERISTICS For a ''b''-order B+ tree with ''h'' levels of index:
RELATIONSHIP TO OTHER DATA STRUCTURES The B+ tree (and most other "B..." trees) are all specialisations of the (a,b)-tree , in which the minimum and maximum order is explicitly defined (the ''a'' and ''b'', respectively). The B+ tree is a variant of the B-tree , the latter of which can store both keys and records in its interior nodes; in this sense, the B+ tree is a specialisation of the B-tree . The B# Tree is a specialisation of the B+ tree, which adds additional restrictions. IMPLEMENTATION The leaves (the bottom-most index blocks) of the B+ tree are often linked to one another in a Linked List ; this makes Range Queries simpler and more efficient (though the aforementioned upper bound can be achieved even without this addition). This does not substantially increase space consumption or maintenance on the tree. If a storage system has a Block Size of ''B'' Bytes , and the keys to be stored have a size of ''k'', arguably the most efficient B+ tree is one where . Although theoretically the one-off is unnecessary, in practice there is often a little extra space taken up by the index blocks (for example, the linked list references in the leaf blocks). Having an index block which is slightly larger than the storage system's actual block represents a significant performance decrease; therefore erring on the side of caution is preferable. If nodes of the B+ tree are organised as arrays of elements, then it may take a considerable time to insert or delete an element as half of the array will need to be shifted on average. To overcome this problem elements inside a node can be organized in a binary tree or a B+ tree instead of an array. B+ trees can also be used for data stored in RAM. In this case a reasonable choice for block size would be the size of processor's Cache Line . However some studies have proved that a block size few times larger than processor's cache line can deliver better performance if Cache prefetching is used. Space efficiency of B+ trees can be improved by using some compression techniques. One possibility is to use Delta Encoding to compress keys stored into each block. For internal blocks, space saving can be achieved by either compressing keys or pointers. For string keys, space can be saved by using the following technique: Normally the i'th entry of an internal block contains the first key of block i+1. Instead of storing the full key, we could store the shortest prefix of the first key of block i+1 that is strictly greater (in lexicographic order) than last key of block i. There is also a simple way to compress pointers: if we suppose that some consecutive blocks i,i+1,,,i+k are stored contiguously, then it will suffice to store only a pointer to the first block and the count of consecutive blocks. All the above compression techniques have some drawbacks. First, a full block must be decompressed to extract a single element. One technique to overcome this problem is to divide each block into sub-blocks and compress them separately. In this case searching or inserting an element will only need to decompress or compress a sub-block instead of a full block. Another drawback of compression techniques is that the number of stored elements may vary considerably from a block to another depending on how well the elements are compressed inside each block. HISTORY The B+ tree was first described in the paper ''Organization and Maintenance of Large Ordered Indices. Acta Informatica 1: 173-189 (1972)'' by Rudolf Bayer and Edward M. McCreight SEE ALSO EXTERNAL LINKS
|
|
|