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

程序填空题:IncreaseKey

Luz4年前 (2021-05-10)题库693
The function is to increase the value of the integer key at position `P` by a positive amount `D` in a max-heap `H`.

```c++
void IncreaseKey( int P, int D, PriorityQueue H )
{
int i, key;
key = H->Elements[P] + D;
for ( i = @@[P](3); H->Elements[i/2] < key; i/=2 )
@@[H->Elements[i] = H->Elements[i/2]](3);
H->Elements[i] = key;
}
```





答案:
第1空:P

第2空:H->Elements[i] = H->Elements[i/2]

发表评论

访客

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