-->
当前位置:首页 > 题库

程序填空题:Percolate Down

Luz5年前 (2021-05-10)题库1110
Please fill in the blanks in the program which percolates down from position `p` in a max-heap `H`.

```c++
void PercolateDown( int p, PriorityQueue H )
{
int child;
ElementType Tmp = H->Elements[p];
for ( ; p * 2 <= H->Size; p = child ) {
child = p * 2;
if ( child!=H->Size && @@[H->Elements[child+1] > H->Elements[child]](3) )
child++;
if ( H->Elements[child] > Tmp )
@@[H->Elements[p] = H->Elements[child]](3);
else break;
}
H->Elements[p] = Tmp;
}
```





答案:
第1空:H->Elements[child+1] > H->Elements[child]

第2空:H->Elements[p] = H->Elements[child]