Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 519 Bytes

Ex_1_5_08.md

File metadata and controls

39 lines (29 loc) · 519 Bytes
title date draft tags categories
Algorithm4 Java Solution 1.5.08
2019-08-21 17:21:57 +0800
false
JAVA
TECH
archives

1.5.08

Problem:

Solution:

code:

Ex_1_5_08.java

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--;
}

Reference: