






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







B-tree
(data structure)
Definition: A balanced search tree in which every node has between m/2 and m children , where m>1 is a fixed integer. m is the order. The root may have as few as 2 children. This is a good structure if much of the tree is in slow memory (disk), since the height , and hence the number of accesses, can be kept small, say one or two, by picking a large m.
2-3 trees are a data structure commonly used to implement ordered lists of records. A 2-3 tree is a tree satisfying the following requirements:
3 : x 7 : x 13 : 27
Example of a 2-3 tree:
Each fork contains the following indices:
3 : x 7 : 8 13 : 27
Same tree after adding the element: 8
Fork
Leaf
To insert a new leaf l in a 2-3 tree, locate the position where the new leaf should be inserted and add the new leaf to the tree. Call p the parent of the newly inserted leaf. If the number of children of p has increased from two to three, we still have a 2- tree and no further change is needed. If the number of children of p has increased from three to four, split p into two nodes with two children each, incrementing the number of children of p 's parent. Proceed recursively up to the root of the tree, and, if needed, add a new root to augment the height of the tree by one.
3 : x 7 : x 13 : 27
9 : x
Insertion continued…
To insert a new leaf l in a 2-3 tree, locate the position where the new leaf should be inserted and add the new leaf to the tree. Call p the parent of the newly inserted leaf. If the number of children of p has increased from two to three, we still have a 2- tree and no further change is needed. If the number of children of p has increased from three to four, split p into two nodes with two children each, incrementing the number of children of p 's parent. Proceed recursively up to the root of the tree, and, if needed, add a new root to augment the height of the tree by one.
3 : x 7 : x 13 : 27
10 : x
9 : x
Insertion completed.
4 : x
8 : x
1+log 3 n <= height(n) <= 1+log 2 n
The time to search, insert or delete is O(log n).