程序填空题:Find
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
```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