This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//QuickUnion algorithm to solve the dynamic connectivity problem, not optimal | |
public class QuickUnion { | |
private int[] id; | |
public QuickUnion(int n){ | |
id = new int[n]; | |
for(int i = 0; i < n; ++i) | |
id[i] = i; | |
} | |
public int getRoot(int n){ |