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.

Sec. 10.5 B-Trees 361331012 233348 101223 33 48 50(a)(b)18 33 48101215 18 20 2123 31 33 45 47 48 50 52(c)331823 48101215 18 20 21 23 30 31 33 45 47 48 50 52Figure 10.20 Examples of B + -tree insertion. (a) A B + -tree containing fiverecords. (b) The result of inserting a record with key value 50 into the tree of (a).The leaf node splits, causing cre<strong>at</strong>ion of the first internal node. (c) The B + -tree of(b) after further insertions. (d) The result of inserting a record with key value 30into the tree of (c). The second leaf node splits, which causes the internal node tosplit in turn, cre<strong>at</strong>ing a new root.(d)priv<strong>at</strong>e BPNode inserthelp(BPNode rt,Key k, E e) {BPNode retval;if (rt.isLeaf()) // At leaf node: insert herereturn ((BPLeaf)rt).add(k, e);// Add to internal nodeint currec = binaryle(rt.keys(), rt.numrecs(), k);BPNode temp = inserthelp(((BPInternal)root).pointers(currec), k, e);if (temp != ((BPInternal)rt).pointers(currec))return ((BPInternal)rt).add((BPInternal)temp);elsereturn rt;}Figure 10.21 A Java-like pseudocode sketch of the B + -tree insert algorithm.

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

Saved successfully!

Ooh no, something went wrong!