1.6 Implementation von "siftdown"

void siftdown(n) {
   int i = 1;     //i ist Wurzel
   while (i hat mindestens einen Sohn) {
      int c = 2*i;      //c ist linker Sohn von i
      if (A[c+1] < A[c])     //kleinsten Sohn finden
         c++;
      if (A[i] > A[c])    //Heap-Eigenschaft gestört
         vertausche i und c;
      i = c;
   }
}

zurück Inhalt vor