Proto Van Emde Boas Trees | Set 4 | Deletion
Please check previous sets of Proto Van Emde Boas Tree article first. It is highly recommended.
Procedure for delete:
- Base Case: If we reach at Proto VEB with size 2 then we will check for whether the key is present or not if yes then we assign the pointer to nullptr which will set false to it presence.
- We recursively call delete function over the cluster of the keys i.e. high(key) and its position low(key).
- After we delete the key from the cluster (after we reach to the base case) we check whether there are any other keys are present in the cluster. If there is any key present then we can not set the summary to nullptr otherwise we will set the summary to nullptr by calling delete over summary.
Lets understand 1 delete on Proto-VEB of size 4:
First it will recursively call delete(cluster, 1).
So now the base case is satisfied so it will go at position 1 in the cluster Proto-VEB and will set it to nullptr if it is present.
Now we will check if any more keys are present in cluster (see the for loop in delete), 0 is present so delete(summary, 0) call is not going to execute and summary will remain same.
See the image below to understand it:
Follow the instructions written near the boxes from top to bottom.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Below is the implementation:
Recurrence Relation for Delete:
T(u) = T(u) = 2T()) + O(log2())
Time Complexity : O(log2(u)*log2(log2(u)))