title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
Algorithm4 Java Solution 1.5.08 |
2019-08-21 17:21:57 +0800 |
false |
|
|
code:
public void badUnion(int p, int q) {
if (connected(p, q))
return;
for (int i = 0; i < id.length; i++) {
// in this implementation, for r > p, the id[d] will not change
if (id[i] == id[p])
id[i] = id[q];
}
PrintUtil.show(id);
count--;
}