public class Part3 {
private static int compares;
private static int swaps;
private static int[] array;
public static void setArray(int[] a) {
array = a;
}
public static int[] bubbleSort(int[] a) {
array = a;
compares = 0;
swaps = 0;
//TO BE IMPLEMENTED
return new int[]{compares, swaps};
}
public static int[] selectionSort(int[] a) {
array = a;
compares = 0;
swaps = 0;
//TO BE IMPLEMENTED
return new int[] {compares, swaps};
}
public static int[] insertionSort(int[] a) {
array = a;
compares = 0;
swaps = 0;
//TO BE IMPLEMENTED
return new int[]{compares, swaps};
}
public static int[] mysterySort(int[] a) {
array = a;
compares = 0;
swaps = 0;
//TO BE IMPLEMENTED
return new int[] {compares, swaps};
}
public static int foo1(int k, int m) {
//TO BE IMPLEMENTED
}
public static void foo2(int k, int m) {
//TO BE IMPLEMENTED
}
public static void foo3() {
//TO BE IMPLEMENTED
}
//returns true if array[i] < array[j]
//false else
//NOTE: You can use !less for >=
private static boolean less(int i, int j) {
compares++;
if(array[i] < array[j])
return true;
return false;
}
//swaps array[i] and array[j]
private static void swap(int i, int j) {
if(i == j)
return;
swaps++;
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
STARTER CODE PROVIDED!!! Need CODE for FOO1,FOO2, FOO3, ANDMYSTERY SORT BASED ON THE FOO METHODS!! ASAP THANK YOU