程序代写 COMP251 template file

import java.io.*;
import java.util.*;

/****************************

Copyright By PowCoder代写 加微信 powcoder

* 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 Union 2 and 3″);
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 Discussion_Board(String[] posts){

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com