12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

378 Chap. 10 Indexing331012 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.18 Examples of B + -tree insertion. (a) A B + -tree containing fiverecords. (b) The result of inserting a record with key value 50 in<strong>to</strong> the tree of (a).The leaf node splits, causing creation of the first internal node. (c) The B + -tree of(b) after further insertions. (d) The result of inserting a record with key value 30in<strong>to</strong> the tree of (c). The second leaf node splits, which causes the internal node <strong>to</strong>split in turn, creating a new root.(d)private BPNode inserthelp(BPNode rt, Key k, E e) {BPNode retval;if (rt.isLeaf()) // At leaf node: insert herereturn ((BPLeaf)rt).add(k, e);// Add <strong>to</strong> 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.19 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!