
   void Heap::Adjust(Type a[], int i, int n)
   // The complete binary trees with roots 2*i and 2*i+1 are
   // combined with node i to form a heap rooted at i. No
   // node has an address greater than n or less than 1.
   {
       int j = 2*i, item = a[i];
       while (j <= n) {
          if ((j<n) && (a[j]<a[j+1])) j++;
             // Compare left and right child
             // and let j be the larger child.
          if (item >= a[j]) break;
             // A position for item is found.
          a[j/2] = a[j]; j *= 2;
       }
       a[j/2] = item;
   }

   bool Heap::DelMax(Type& item)
   {   if (!Nel) { cout << "heap is empty"
                   << endl; return false;
       }
       item=array[1]; array[1]=array[Nel--];
       Adjust(array, 1, Nel); return true;
   }

