patternMinor
How the deletion takes place in B+ Tree
Viewed 0 times
theplacehowdeletiontakestree
Problem
My professor was giving a lecture on B+ Trees deletion, and I got very confused. According to him for deleting any key from a B+ Tree:
If you see the below image, here I want to delete 19 and 20 from the B+ Tree.
After deleting 19 and 20 from the B+ Tree.
Question:
I am confused why the redistribution and merging is required here at all? If you just simply delete 19 and 20 from the leaf nodes without any distribution it should work right? Why redistribution is performed here? Could anyone explain?
Is it because the left pointer of 24 is pointing to 20 but no 19.
Thats why redistribution is required for 20 but not 19.
1- First navigate to the leaf *L* where it belongs.
2- If the *L* is at least half full if you can simply delete it.
3- If it contains d-1 elements then you need to redistribute and merge.If you see the below image, here I want to delete 19 and 20 from the B+ Tree.
After deleting 19 and 20 from the B+ Tree.
Question:
I am confused why the redistribution and merging is required here at all? If you just simply delete 19 and 20 from the leaf nodes without any distribution it should work right? Why redistribution is performed here? Could anyone explain?
Is it because the left pointer of 24 is pointing to 20 but no 19.
Thats why redistribution is required for 20 but not 19.
Solution
Okay I understood the issue.
Properties of B+ Tree.
-
All leaves should be at the same depth, and the mininum element in each leaf node should be equal to depth of the tree. See the example below:
-
All the leaves are in same depth, and here d = 2.
In the B+ Tree given below, each node has
Only root of the B+ Tree can only fewer than d keys, its the only exception we have.
In my question, when you remove
Properties of B+ Tree.
-
All leaves should be at the same depth, and the mininum element in each leaf node should be equal to depth of the tree. See the example below:
-
All the leaves are in same depth, and here d = 2.
- Each leaf node must contain d number of elements, otherwise redistribution and merging has to be performed.
- All the data pointers are contained in leaf nodes.
- All elements should be contained in leaf nodes.
- There should be between
dto2*dkeys at node except possibly the root.
- There should be between
d + 1to2*d + 1child pointers.
In the B+ Tree given below, each node has
2 and 2*2 data entries except possible the root. Each node has a mininum of 2 keys.Only root of the B+ Tree can only fewer than d keys, its the only exception we have.
In my question, when you remove
19, the property of B+ Tree is not violated but when you remove 20, the total number of elements contained in the node is less than d. Hence redistribution and merging have to be performed so that the property of B+ tree is not violated.Context
StackExchange Computer Science Q#50384, answer score: 5
Revisions (0)
No revisions yet.