void siftDown(int *a, int start, int end){ int root = start; while ( root*2+1 < end ) { int child = 2*root + 1; if ((child + 1 < end) && IS_LESS(a[child],a[child+1])) { child += 1; }//if if (IS_LESS(a[root], a[child])) { SWAP( a[child], a[root] ); root = child; }/*if*/ else { return; }//else }//while }//siftDown
void sift_down(int *a, int start, int end) { int root = start; while ( root * 2 + 1 < end ) { int child = 2 * root + 1; if ((child + 1 < end) && IS_LESS(a[child], a[child + 1])) { child += 1; } if (IS_LESS(a[root], a[child])) { SWAP( a[child], a[root] ); root = child; } else return; } }