B-Tree

# B-Tree - B-tree From Wikipedia the free encyclopedia Not to...

This preview shows pages 1–4. Sign up to view the full content.

B-tree From Wikipedia, the free encyclopedia Not to be confused with Binary tree . A B-tree of order 2 ( Bayer & McCreight 1972 ) or order 5 ( Knuth 1997 ). In computer science , a B-tree is a tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic amortized time . The B-tree is a generalization of a binary search tree in that more than two paths diverge from a single node. ( Comer , p. 123) Unlike self-balancing binary search trees , the B-tree is optimized for systems that read and write large blocks of data. It is commonly used in databases and filesystems . Contents [ hide ] 1 Overview o 1.1 Variants o 1.2 Etymology unknown 2 The database problem o 2.1 Time to search a sorted file o 2.2 An index speeds the search o 2.3 Insertions and deletions cause trouble o 2.4 The B-tree uses all those ideas 3 Technical description o 3.1 Terminology o 3.2 Definition 4 Best case and worst case heights 5 Algorithms

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
o 5.1 Search o 5.2 Insertion o 5.3 Deletion 5.3.1 Deletion from a leaf node 5.3.2 Deletion from an internal node 5.3.3 Rebalancing after deletion o 5.4 Initial construction 6 B-trees in filesystems 7 Notes o 7.1 Access concurrency 8 See also 9 References o 9.1 Original papers 10 External links [ edit ] Overview In B-trees internal (non-leaf) nodes can have a variable number of child nodes within some pre-defined range. When data is inserted or removed from a node, its number of child nodes changes. In order to maintain the pre-defined range, internal nodes may be joined or split. Because a range of child nodes is permitted, B-trees do not need re-balancing as frequently as other self-balancing search trees , but may waste some space, since nodes are not entirely full. The lower and upper bounds on the number of child nodes are typically fixed for a particular implementation. For example, in a 2-3 B-tree (often simply referred to as a 2-3 tree ), each internal node may have only 2 or 3 child nodes. Each internal node of a B-tree will contain a number of keys. Usually, the number of keys is chosen to vary between d and 2 d . In practice, the keys take up the most space in a node. The factor of 2 will guarantee that nodes can be split or combined. If an internal node has 2 d keys, then adding a key to that node can be accomplished by splitting the 2 d key node into two d key nodes and adding the key to the parent node. Each split node has the required minimum number of keys. Similarly, if an internal node and its neighbor each have d keys, then a key may be deleted from the internal node by combining with its neighbor. Deleting the key would make the internal node have d − 1 keys; joining the neighbor would add d keys plus one more key brought down from the neighbor's parent. The result is an entirely full node of 2 d keys.
The number of branches (or child nodes) from a node will be one more than the number of keys stored in the node. In a 2-3 B-tree, the internal nodes will store either one key (with two child nodes) or two keys (with three child nodes). A B-tree is sometimes described with the parameters

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern