程序代写 COMP251 template file – cscodehelp代写
import java.io.*;
import java.util.*;
/****************************
Copyright By cscodehelp代写 加微信 cscodehelp
* COMP251 template file
* Assignment 1, Question 2
*****************************/
public class DisjointSets {
private int[] par;
private int[] rank;
/* contructor: creates a partition of n elements. */
/* Each element is in a separate disjoint set */
DisjointSets(int n) {
if (n>0) {
par = new int[n];
rank = new int[n];
for (int i=0; i
myset.union(2,3);
System.out.println(myset);
System.out.println(“-> Union 2 and 3”);
myset.union(2,3);
System.out.println(myset);
System.out.println(“-> Union 2 and 1”);
myset.union(2,1);
System.out.println(myset);
System.out.println(“-> Union 4 and 5”);
myset.union(4,5);
System.out.println(myset);
System.out.println(“-> Union 3 and 1”);
myset.union(3,1);
System.out.println(myset);
System.out.println(“-> Union 2 and 4”);
myset.union(2,4);
System.out.println(myset);
import java.util.*;
public class A1_Q3 {
public static ArrayList
程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: kyit630461@163.com