/* * Student First Name: * Student Last Name: * Student BU Number: * Purpose: */ public class Set { private static final int SIZE = 10; // default size of initial set private int[] set; // array referece to the set private int size; // current size of the set private int next; // index to next available slot in the set array public Set() { // your code here } /* public Set(int[] arr) { // your code here } public Set clone() { // your code here } public void insert(int k) { // your code here } */ /** * This method reallocates the array set to twice as * big and copies all the elements over. * This method is called only by the insert method * when it cannot insert another element to the set. * * Note that this is the reason that in this class * the member size is not a class variable (i.e. static) * and it is not final, because the set can grow and size * will be modified accordingly. */ private void resize() { size *= 2; // Create a new array double the size int[] temp = new int[size]; // Copy all the elements from the current set // to the new set for(int i = 0; i < set.length; ++i) { temp[i] = set[i]; } // Assign to the set reference the newly // resized array that represents the set. set = temp; } /* * Uncomment each method as you implement * public String toString() { // your code here } public int cardinality() { // your code here } public boolean isEmpty() { // your code here } public boolean member(int k) { // your code here } public boolean subset(Set S) { // your code here } public boolean equal(Set S) { // your code here } public void delete(int k) { // your code here } public Set union(Set S) { // your code here } public Set intersection(Set S) { // your code here } public Set setdifference(Set S) { // your code here } */ }