11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

362 Chap. 10 Indexing3318 23 48101215 19 2021 22 23 30 31 33 45 47 48 50 52Figure 10.22 Simple deletion from a B + -tree. The record with key value 18 isremoved from the tree of Figure 10.18. Note th<strong>at</strong> even though 18 is also a placeholderused to direct search in the parent node, th<strong>at</strong> value need not be removedfrom internal nodes even if no record in the tree has key value 18. Thus, theleftmost node <strong>at</strong> level one in this example retains the key with value 18 after therecord with key value 18 has been removed from the second leaf node.3319 2348101518 19 20 21 22 23 30 31 33 45 47 48 50 52Figure 10.23 Deletion from the B + -tree of Figure 10.18 via borrowing from asibling. The key with value 12 is deleted from the leftmost leaf, causing the recordwith key value 18 to shift to the leftmost leaf to take its place. Note th<strong>at</strong> the parentmust be upd<strong>at</strong>ed to properly indic<strong>at</strong>e the key range within the subtrees. In thisexample, the parent node has its leftmost key value changed to 19.records to contribute to the current node), <strong>and</strong> N has become less than half fullbecause it is under-flowing. This merge process combines two subtrees of the parent,which might cause it to underflow in turn. If the last two children of the rootmerge together, then the tree loses a level. Figure 10.24 illustr<strong>at</strong>es the node-mergedeletion process. Figure 10.25 shows Java-like pseudocode for the B + -tree deletealgorithm.The B + -tree requires th<strong>at</strong> all nodes be <strong>at</strong> least half full (except for the root).Thus, the storage utiliz<strong>at</strong>ion must be <strong>at</strong> least 50%. This is s<strong>at</strong>isfactory for manyimplement<strong>at</strong>ions, but note th<strong>at</strong> keeping nodes fuller will result both in less spacerequired (because there is less empty space in the disk file) <strong>and</strong> in more efficientprocessing (fewer blocks on average will be read into memory because the amountof inform<strong>at</strong>ion in each block is gre<strong>at</strong>er). Because B-trees have become so popular,many algorithm designers have tried to improve B-tree performance. One methodfor doing so is to use the B + -tree variant known as the B ∗ -tree. The B ∗ -tree isidentical to the B + -tree, except for the rules used to split <strong>and</strong> merge nodes. Insteadof splitting a node in half when it overflows, the B ∗ -tree gives some records to its

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!