160 likes | 298 Views
B-Trees. Text Read Weiss, § 4.7 B-Tree Objects Leaf, Interior Node, Information Packet, B-Tree Deleting Records from a B-Tree Need to combine leaves Need to combine interior nodes. Example Step-Through. Assume Order 3 B-Tree, i.e., L = M = 3 Each leaf can hold at most 3 records
E N D
B-Trees • Text • Read Weiss, §4.7 • B-Tree Objects • Leaf, Interior Node, Information Packet, B-Tree • Deleting Records from a B-Tree • Need to combine leaves • Need to combine interior nodes
Example Step-Through • Assume Order 3 B-Tree, i.e., L = M = 3 • Each leaf can hold at most 3 records • Each interior node can hold at most 2 keys and 3 references to children
● 15 ● 35● root ● 6 ● 12 ● ● 17 ● 27● ● 42 ● 54● 4 5 12 13 15 16 17 24 27 29 31 35 39 42 47 54 59 61 6 7 Start with an already initialized B-Tree
● 15 ● 35● root ● 6 ● 12 ● ● 17 ● 27● ● 42 ● 54● 4 5 12 13 15 16 17 24 27 29 31 35 39 42 47 54 59 61 6 7 Delete 27
● 15 ● 35● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 35 39 42 47 54 59 61 6 7 Delete 61
● 15 ● 35● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 35 39 42 47 54 59 6 7 Delete 61
● 15 ● 35● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 35 39 42 47 54 59 6 7 Delete 35
● 15 ● 39 ● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 39 42 47 54 59 6 7 Policy: Allow 39 to remain alone in leaf
● 15 ● 39 ● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 39 42 47 54 59 6 7 Delete 39
● 15 ● 39 ● root ● 6 ● 12 ● ● 17 ● 29● ● 42 ● 54● 4 5 12 13 15 16 17 24 29 31 42 47 54 59 6 7 Delete 39
● 15 ● 42 ● root ● 6 ● 12 ● ● 17 ● 29● ● 54 ● __● 4 5 12 13 15 16 17 24 29 31 42 47 54 59 6 7 Delete 39
● 15● 42 ● root ● 6 ● 12 ● ● 17 ● 29● ● 54 ● __● 4 5 12 13 15 16 17 24 29 31 42 47 54 59 6 7 Delete 15, 16
● 17 ● 42● root ● 6 ● 12 ● ● 29 ● __● ● 54 ● __● 4 5 12 13 17 24 29 31 42 47 54 59 6 7 Delete 35, 39, 15, 16
● 17 ● 42● root ● 6 ● 12 ● ● 29 ● __● ● 54● __● 4 5 12 13 17 24 29 31 42 47 54 59 6 7 Delete 54, 59
● 17 ● 42● root ● 6 ● 12 ● ● 29 ● __● ● __ ● __● 4 5 12 13 17 24 29 31 42 47 6 7 Must move leaf
● 17 ● __● root ● 6 ● 12 ● ● 29 ● 42 ● 4 5 12 13 17 24 29 31 42 47 6 7 Must move leaf (adoption of child)