程序填空题:Union - Find
Please fill the array with the results after the following union/find operations.
```
union( find(4), find(6) )
union( find(2), find(7) )
union( find(0), find(4) )
union( find(7), find(6) )
union( find(7), find(1) )
```
Note: Assume `union-by-size` (if two sets are equal-sized, the first root will be the root of the result) and `find-with-path-compression`. `S[i]` is initialized to be $$-1$$ for all $$0\le i\le 7$$.
| `i` | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|`S[i]`| $$4$$ |@@[4](1) |@@[4](1)|$$-1$$| @@[-6](1)|$$-1$$|$$4$$|@@[4](1)|
答案:
第1空:4
第2空:4
第3空:-6
第4空:4
```
union( find(4), find(6) )
union( find(2), find(7) )
union( find(0), find(4) )
union( find(7), find(6) )
union( find(7), find(1) )
```
Note: Assume `union-by-size` (if two sets are equal-sized, the first root will be the root of the result) and `find-with-path-compression`. `S[i]` is initialized to be $$-1$$ for all $$0\le i\le 7$$.
| `i` | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|:--:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|`S[i]`| $$4$$ |@@[4](1) |@@[4](1)|$$-1$$| @@[-6](1)|$$-1$$|$$4$$|@@[4](1)|
答案:
第1空:4
第2空:4
第3空:-6
第4空:4