hi i have question here is pseudo code about sift up and sift down on heaps
Posted
by davit-datuashvili
on Stack Overflow
See other posts from Stack Overflow
or by davit-datuashvili
Published on 2010-05-24T10:51:49Z
Indexed on
2010/05/24
11:11 UTC
Read the original article
Hit count: 298
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?
© Stack Overflow or respective owner