程序填空题:大顶堆的下滤
下列代码的功能是从一个大顶堆`H`的某个指定位置`p`开始执行下滤。
```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]
```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]