-->
当前位置:首页 > 题库 > 正文内容

程序填空题:Percolate Down

Luz4年前 (2021-05-10)题库981
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]

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。