Question: test file : public class Lab5_2017 { // you need to change the package name and class name before using this test class public static

 test file : public class Lab5_2017 { // you need tochange the package name and class name before using this test classpublic static void main(String[] args) { // parameters inpt here int arr[]

test file :

public class Lab5_2017 { // you need to change the package name and class name before using this test class public static void main(String[] args) { // parameters inpt here int arr[] = {1,2,3,7,8}; // this list int uni1[] = {0,2,3,8,10,20}; int uni2[] = {0,2,3}; // for testing union int inter1[] = {0,2,7}; int inter2[] = {1,3,5,6,8,10}; int inter3[] = {0,10,100}; //test intersection int diff1[] = {1,2,3,5,7,8,9}; int diff2[] = {1,2,3}; // test difference int arr1[] = {0,1,2}; int arr2[] = {1,2,3,4}; int arr3[] = {0,1}; int arr4[] = {6,7}; SLLSet listObj100 = new SLLSet(arr1); SLLSet listObj99 = new SLLSet(arr2); SLLSet listObj98 = new SLLSet(arr3); SLLSet listObj97 = new SLLSet(arr4); SLLSet listObj96 = new SLLSet(); SLLSet Array[] = {listObj100,listObj99,listObj98,listObj97,listObj96}; // test static SLLSet union(sArray) int in = 2; int notin = 0; // test isIn int notadd = 3; int addmiddle = 4; int addlast = 9; int addfirst = 0; // test add int notremove = 10; int removemiddle = 3; int removelast = 8; int removefirst = 1; // test remove /////////////////////////////// end parameter /////////////////////////////////////// //test constructor 1 SLLSet listObj1= new SLLSet(); System.out.println("Test 1 - Constructor 1: "+"List: "+ listObj1.toString()); System.out.println("size = "+listObj1.getSize()); System.out.println("*************************************************************"); //test constructor 2 with sorted input without repetitions SLLSet listObj2= new SLLSet(arr); System.out.println("Test 2 - Constructor 2 (sorted input): "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); //test copy SLLSet copied= listObj2.copy(); copied.add(100); System.out.println("Test 3 - Copy(Change in copy should not affect the initial set): "+"Copy List: "+copied.toString()); System.out.println("size="+copied.getSize()); System.out.println("Initial "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); //test isIn System.out.println("Test 4 - isIn(in): "+in+" is in the list? "+listObj2.isIn(in)); System.out.println("*************************************************************"); System.out.println("Test 5 - isIn(not in): "+notin+" is in the list? "+listObj2.isIn(notin)); System.out.println("*************************************************************"); //test add listObj2.add(notadd); System.out.println("Test 6 - add(the value is in the list, then do nothing): "+notadd+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.add(addmiddle); System.out.println("Test 7 - add(middle): "+addmiddle+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.add(addlast); System.out.println("Test 8 - add(last): "+addlast+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.add(addfirst); System.out.println("Test 9 - add(first): "+addfirst+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); //test remove listObj2= new SLLSet(arr); listObj2.remove(notremove); System.out.println("Test 10 - remove(the value is not in the list, then do nothing): "+notremove+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.remove(removemiddle); System.out.println("Test 11 - remove(middle): "+removemiddle+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.remove(removelast); System.out.println("Test 12 - remove(last): "+removelast+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); listObj2.remove(removefirst); System.out.println("Test 13 - remove(first): "+removefirst+" "+"List: "+listObj2.toString()); System.out.println("size="+listObj2.getSize()); System.out.println("*************************************************************"); SLLSet emp = new SLLSet(); emp.remove(removefirst); System.out.println("Test 14 - remove(from empty list): "+removefirst+" "+"List: "+emp.toString()); System.out.println("size="+emp.getSize()); System.out.println("*************************************************************"); // test union listObj2= new SLLSet(arr); SLLSet listObj3= new SLLSet(); SLLSet listObj4 = listObj2.union(listObj3); System.out.println("Test 15 - union(s list is empty): "+"List: "+listObj4.toString()); System.out.println("size="+listObj4.getSize()); System.out.println("*************************************************************"); SLLSet listObj5= new SLLSet(uni1); SLLSet listObj6 = listObj2.union(listObj5); System.out.println("Test 16 - union(): "+"List: "+listObj6.toString()); System.out.println("size="+listObj6.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj5.toString()); System.out.println("*************************************************************"); SLLSet listObj7= new SLLSet(uni2); SLLSet listObj8 = listObj2.union(listObj7); System.out.println("Test 17 - union(): "+"List: "+listObj8.toString()); System.out.println("size="+listObj8.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj7.toString()); System.out.println("*************************************************************"); SLLSet listObj40 = listObj3.union(listObj2); System.out.println("Test 18 - union(this list is empty): "+"List: "+listObj40.toString()); System.out.println("size="+listObj40.getSize()); System.out.println("*************************************************************"); // test intersection listObj2= new SLLSet(arr); SLLSet listObj9= new SLLSet(); SLLSet listObj10 = listObj2.intersection(listObj9); System.out.println("Test 19 - intersection(s list is empty): "+"List: "+listObj10.toString()); System.out.println("size="+listObj10.getSize()); System.out.println("*************************************************************"); SLLSet listObj11= new SLLSet(inter1); SLLSet listObj12 = listObj2.intersection(listObj11); System.out.println("Test 20 - intersection(): "+"List: "+listObj12.toString()); System.out.println("size="+listObj12.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj11.toString()); System.out.println("*************************************************************"); SLLSet listObj13= new SLLSet(inter2); SLLSet listObj14 = listObj2.intersection(listObj13); System.out.println("Test 21 - intersection(): "+"List: "+listObj14.toString()); System.out.println("size="+listObj14.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj13.toString()); System.out.println("*************************************************************"); SLLSet listObj15= new SLLSet(inter3); SLLSet listObj16 = listObj2.intersection(listObj15); System.out.println("Test 22 - intersection(no elements in common): "+"List: "+listObj16.toString()); System.out.println("size="+listObj16.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj15.toString()); System.out.println("*************************************************************"); SLLSet listObj50 = listObj9.intersection(listObj2); System.out.println("Test 23 - intersection(this list is empty): "+"List: "+listObj50.toString()); System.out.println("size="+listObj50.getSize()); System.out.println("*************************************************************"); // test difference listObj2= new SLLSet(arr); SLLSet listObj17= new SLLSet(); SLLSet listObj18 = listObj2.difference(listObj17); System.out.println("Test 24 - difference(s list is empty): "+"List: "+listObj18.toString()); System.out.println("size="+listObj18.getSize()); System.out.println("*************************************************************"); SLLSet listObj19= new SLLSet(diff1); SLLSet listObj20 = listObj2.difference(listObj19); System.out.println("Test 25 - difference(this list is in s list): "+"List: "+listObj20.toString()); System.out.println("size="+listObj20.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj19.toString()); System.out.println("*************************************************************"); SLLSet listObj21= new SLLSet(diff2); SLLSet listObj22 = listObj2.difference(listObj21); System.out.println("Test 26 - difference(): "+"List: "+listObj22.toString()); System.out.println("size="+listObj22.getSize()); System.out.println("This list is: "+listObj2.toString()); System.out.println("s list is: "+listObj21.toString()); System.out.println("*************************************************************"); SLLSet listObj1000 = listObj17.difference(listObj2); System.out.println("Test 27 - difference(this list is empty): "+"List: "+listObj1000.toString()); System.out.println("size="+listObj1000.getSize()); System.out.println("*************************************************************"); // test union(sArray) SLLSet listObj23 = SLLSet.union(Array); System.out.println("Test 28 - union(sArray): "+"List: "+listObj23.toString()); System.out.println("size="+listObj23.getSize()); System.out.println("*************************************************************"); } }

A set is an unordered collection of elements with no repetitions. Examples are the set of real numbers, the set of integer numbers or the set consisting of nmbers 1, 2,30. Examples: 10,34,78, 1000), 4,5, 890,63535], [0,1,2...,65534,65535), are all valid sets The union of two sets, say A and B, is written as AUB and is the set which contains all elements in either A or B or both. Example: If A 3,8, 14, 15 and B-12,8,9,15, 100], then AUB 12,3,8,9,14, 15,100) (otice that there are no repeated elements in ase . The intersection of two sets A and B is written as AnB and is the set which contains the elements that are common to A and B. Examples: If A = {3,8, 14,15) and then An B { }, which is termed the empty set. those elements which are in A and are not in B. Example: If A 13, 8, 14, 15 A+ {17, 20, 38) sid B = (200). . The difference of two sets A and B is written as AB and is the set containing and 1-12, 8, 9, 15, 100), then A \ B-{3, 14) and B \ A (2, 9, 100} SPECIFICATIONS You may use the following Java class SLLNode: class SLLNodet int value SLLNode next: public SLLNode (int i, SLLNode n) { value = 1; next = n; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!