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

程序填空题:Find

Luz4年前 (2021-05-10)题库1671
Please fill in the blanks in the program which performs `Find` as a Union/Find operation with path compression.

```c++
SetType Find ( ElementType X, DisjSet S )
{
ElementType root, trail, lead;

for ( root = X; S[root] > 0; @@[root = S[root]](3) ) ;
for ( trail = X; trail != root; trail = lead ) {
lead = S[trail] ;
@@[S[trail] = root](3);
}
return root;
}
```





答案:
第1空:root = S[root]

第2空:S[trail] = root

发表评论

访客

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