import java.util.*; public class SortTest { // mix up the elements in the array // private static void MixArrayElements(int a[]) { } // generate and print a few random numbers in // interval [0, (range-1)] // public static void TestRandom(int range) { System.err.println("Running TestRandom ..."); Random r = new Random(); System.err.println(r.nextInt(range)); System.err.println(r.nextInt(range)); System.err.println(r.nextInt(range)); } // Demonstrate use of timing methods: // prints time spent iterating in a (purposeless) for loop // public static void TimeTest (int iterations) { System.err.println("Running TimeTest..."); double temp = 0; long startTime, finishTime; startTime = System.currentTimeMillis(); for (long i = 0; i < iterations; i++) temp += (i*i)%2; finishTime = System.currentTimeMillis(); System.err.println( "Elapsed time (milliseconds): " + (finishTime - startTime)); } // swap elements a[i] and a[j] // public static void Swap(int a[], int i, int j) { int temp; temp = a[i]; a[i] = a[j]; a[j] = temp; } // Bubble Sort - you probably should never use this // in a real application! // public static void BubbleSort (int a[]) { System.err.println("Running BubbleSort ..."); int maxIndex = a.length-1; for (int i = 0; i <= maxIndex; i++) { for (int j = maxIndex; j > i; j--) if (a[j-1]>a[j]) Swap(a,j-1,j); } } private static void printarray(int a[], int lo, int hi) { for (int i = lo; i