next up previous
Next: Insert: B-Tree-Insert(T, k) Up: CSE 2320: Algorithms and Previous: Splitting: B-Tree-Split-Child(x, i, y)

Splitting: B-Tree-Split-Child(x, i, y)

B-Tree-Split-Child(x, i, y) $\;\;\;\;\;$ $\;\;\;\;\;$; x is parent, y is child in ith subtree
$\;\;\;\;\;$Allocate(z) $\;\;\;\;\;$ $\;\;\;\;\;$ $\;\;\;\;\;$ $\;\;\;\;\;$; n(z)=t-1, leaf(z) = leaf(y)
$\;\;\;\;\;$Copy y's second half keys and children to z
$\;\;\;\;\;$n(y) = t-1
$\;\;\;\;\;$Shift x's keys and children one to the right from i
$\;\;\;\;\;$childi+1(x) = z
$\;\;\;\;\;$keyi(x) = keyt(y)
$\;\;\;\;\;$n(x) = n(x) + 1
$\;\;\;\;\;$Write(x)
$\;\;\;\;\;$DiskWrite(y)
$\;\;\;\;\;$DiskWrite(z)

Running time is $\Theta(t)$ with 3 disk writes



Copyright © 1998 The University of Texas at Arlington