Documente Academic
Documente Profesional
Documente Cultură
Eric Nevala
The concept of deleting from a B-Tree A graphical illustration of all the cases of deletion Look at some implementations in C++ code Do some practical exercises for practice (cards -> whiteboard)
The Concept
You can delete a key entry from any node. ->Therefore, you must ensure that before/after deletion, the B-Tree maintains its properties. When deleting, you have to ensure that a node doesnt get too small (minimum node size is T 1). We prevent this by combining nodes together.
Simple Deletion
Case 1: We delete F
Result: We remove F from the leaf node. No further action needed.
Result: We remove M from the parent node. Since there are four nodes and two letters, we move L to replace M. Now, the N O node has a parent again.
The rule:
You must have n+1 child nodes. If you delete an intermediate node, you need to replace the missing node by promoting a child key. If you dont go below the minimum t on the right, then take the right most node from the left branch, otherwise try the right left most node on the right branch.
Result: First, we combine nodes DE and JK. Then, we push down G into the DEJK node and delete it as a leaf.
The rule
Condition: You must delete a key. The key has a minimum number of nodes on the left and right branches. Action: Take the key to be deleted, move it down, and then combine the left and right branches. Then delete the key.
The rule
The recursion cant descend down to node CL because it only has two keys, so P is pushed down to the end of CL and merged with TX to form CLPTX; Then, D is deleted as in the first rule.
Deleting B
Before:
The rule
Conditions:
Deleting
the key from the node would result in a node smaller then the minimum allowable size The neighboring node has extra keys
Actions:
Take
the parent key and overwrite the node youre deleting Take the left most node from the right neighbor and promote it to the parent key
Remove_data
Copy_in_predecessor
Combination Illustration
Quick Exercise
Remove C, P and V from this B-Tree.
Work with the guy next to you to compare and check your work. Which ever pair can correctly remove all three the fastest is awesome!