To delete a key in a B-tree: Step 1. If the key k is in node x and x is a leaf, delete the key k from x. Step 2. If the key k is in node x and x is an internal node, do the following: 2a) If the child y that precedes k in node x has at least t keys, then find the predecessor k’ of k in the sub-tree rooted at y. Recursively delete k’, and replace k by k’ in x. (We can find k’ and delete it in a single downward pass.) 2b) If y has fewer than t keys, then, symmetrically, examine the child z that follows k in node x. If z has at least t keys, then find the successor k’ of k in the subtree rooted at z. Recursively delete k’, and replace k by k’ in x. (We can find k’ and delete it in a single downward pass.) 2c) Otherwise, if both y and z have only t-1 keys, merge k and all of z into y, so that x loses both k and the pointer to z, and y now contains 2t-1 keys. Then free z and recursively delete k from y. Answer the following regarding insertion/deletion of keys in a B-Tree: (1) Show the results of inserting the keys: F, L, O, R, I, D, A, U, N, V, M, Y, C, S in order into an empty B-tree with minimal degree 2. Draw only the configurations of the tree just before some node being split, and also draw the final configuration; (2) Write pseudo code for Step (1) for function B-Tree-Delete-Key(x, k). Identify a node in the above example for this case and show the result after the deletion. (3) Write pseudo code for Step (2a) for function B-Tree-Delete-Key(x, k). Identify a node in the above example for this case and show the result after the deletion.
To delete a key in a B-tree:
Step 1. If the key k is in node x and x is a leaf, delete the key k from x.
Step 2. If the key k is in node x and x is an internal node, do the following:
2a) If the child y that precedes k in node x has at least t keys, then find the predecessor k’ of k in the sub-tree rooted at y. Recursively delete k’, and replace k by k’ in x. (We can find k’ and delete it in a single downward pass.)
2b) If y has fewer than t keys, then, symmetrically, examine the child z that follows k in node x. If z has at least t keys, then find the successor k’ of k in the subtree rooted at z. Recursively delete k’, and replace k by k’ in x. (We can find k’ and delete it in a single downward pass.)
2c) Otherwise, if both y and z have only t-1 keys, merge k and all of z into y, so that x loses both k and the pointer to z, and y now contains 2t-1 keys. Then free z and recursively delete k from y.
Answer the following regarding insertion/deletion of keys in a B-Tree:
(1) Show the results of inserting the keys: F, L, O, R, I, D, A, U, N, V, M, Y, C, S in order into an empty B-tree with minimal degree 2. Draw only the configurations of the tree just before some node being split, and also draw the final configuration;
(2) Write pseudo code for Step (1) for function B-Tree-Delete-Key(x, k). Identify a node in the above example for this case and show the result after the deletion.
(3) Write pseudo code for Step (2a) for function B-Tree-Delete-Key(x, k). Identify a node in the above example for this case and show the result after the deletion.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps