This is program for max heapify ,i have doubt int this algorithm,that if a already max heap is passed into this function MAX_HEAPIFY
in that case largest
will equal to i
only and directly recursive call to MAX_HEAPIFY
will execute only in that recursion will go infinitely
i am assuming that array index is starting from 1 instead of zero
MAX_HEAPIFY(A,i,heapsize){
l=2i;
r=2i+1;
if(l<=heapsize&& A[l]>A[i])
largest=l;
else
largest=i;
if(r<=heapsize&&A[r]>A[largest])
largest=r;
if(largest!=i)
swap(A[i],A[largest])
MAX_HEAPIFY(A,largest)
}