Removing the Min Element from Deaps

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

Now we shall explain the technique for removing the min elements in the deap data structure. During deletion, our main target to delete the minimal value from deaps. As the height of the tree is always log n, it consumes time of order of log n. We can discuss deletion operation as follows −

Procedure deap_deletion(b[],m):
if(m<2)
   return; //There are no elements.
min=b[2]; //Minimum value is saved
for (i=2;2*i<=m;b[i]=b[k],i=k){
   k=i*2;
   If(k+1<=m && b[k]>b[k+1])
      k++;
   }
   k=max_value(i);
   if(x>b[k]){
      b[i]=b[k];
      insert y into maximum subtree;
   } else {
      insert y into minimum subtree;
}
raja
Published on 03-Jan-2020 05:39:55
Advertisements