I did these in pascal.
Proceure Max_Heapify(a:Table;i:longint);
var tmp,l,r,k:longint;
begin
l:=2*i;
r:=2*i+1;
if (heapsize>=l)and(a[i]<a[l]) then k:=l else k:=i;
if (heapsize>=r)and(a[i]<a[r]) then k:=r;
if k<>i then
begin
swap(a[i],a[k]);
Max_Heapify(a,k);
end;
end;
I wrote this procedure in pascal, but it seems not working and I can't figure out what's wrong can somebody help me ? Thanks