void buildHeap(int *heap1, int CAP)
{
for(int j=CAP; j>0; j--)
{
for(int i=((CAP-1)/2); i>=0; i--)
{
heapify(heap1, CAP, i);
}
}
};
void heapify(int *heap, int CAP, int i)
{
int l, r, largest;
l=2*i+1;
r=2*i+2;
if(r==CAP)
{
largest=l;
r=l;
}
if(heap[r]>heap[i])
{
int temp;
temp=heap[i];
heap[i]=heap[r];
heap[r]=temp;
}
if(heap[l]>heap[i])
{
int temp;
temp=heap[i];
heap[i]=heap[l];
heap[l]=temp;
}
return;
};