Example #1
0
int percolateDown(int n, int i, Node *_elem)
{
    int j;
    j = ProperParent(_elem, n ,i);
    while (i != j)
    {
        swap(_elem[i], _elem[j]);
        i = j;
        j = ProperParent(_elem, n ,i);
    }
    
    return i;
}
Example #2
0
Rank PQ_ComplHeap<T>::percolateDown(Rank n, Rank i) {
    Rank j;//i及其(至多两个)孩子中,堪为夫者
    while (i != (j = ProperParent(_elem, n ,i) ) )//只要i非j,则
    {   swap(_elem[i], _elem[j]);
        i = j;
    }
    return i;
}