hi i have question here is pseudo code about sift up and sift down on heaps
- by davit-datuashvili
i have following pseudo code :
void siftup(int n)
pre condition n>0 && heap(1,n-1)
post heap(1,n)
i=n;
loop
/* invariant: heap(1,n) except perhaps
between i and its parent
if (i==1)
break;
p=i/2;
if (x[p]<=x[i])
break;
swap(p,i);
i=p;
please help me to write it in real code i have question about loop for example where is starting point of loop?