public class ex3 { public static int NUMITEMS = 5; public static int NUMPROCESSORS = 3; private static final boolean debug = true; static int[] myAlgorithm (double[] taskTimes, int numProcessors) { // INSERT YOUR CODE HERE. // What to return: // Create an int array called partition such that // partition[i] = the index of the last task assigned to processor i. // Thus, if 5 tasks break up into 3 processors as: // Processor 0: 0, 1 // Processor 1: 2, 3 // Processor 2: 4 // Then, // partition[0] = 1 (implying the range 0 to 1) // partition[1] = 3 (implying the range 2 to 3) // partition[2] = 4 (implying the range 4 to 4) // Temporarily: return null; } public static void main (String[] argv) { test(); } public static void test () { // Test1: int numProcessors = 3; double[] taskTimes = {50, 23, 62, 72, 41}; System.out.println ("Test1: (optimal time: 113)"); runTest (taskTimes, numProcessors); // Test2: numProcessors = 2; double[] taskTimes2 = {50, 23, 62, 72, 41}; System.out.println ("Test2: (optimal time: 135)"); runTest (taskTimes2, numProcessors); // Test3: numProcessors = 6; double[] taskTimes3 = {50, 23, 62, 72, 41, 17, 68, 12, 19, 45}; System.out.println ("Test3: (optimal time: 76)"); runTest (taskTimes3, numProcessors); } static void runTest (double[] taskTimes, int numProcessors) { int[] partition = myAlgorithm (taskTimes, numProcessors); double cost = cost (taskTimes, partition, numProcessors, true); System.out.println ("MYALGORITHM: numTasks=" + taskTimes.length + " numProcessors=" + numProcessors + " Final completion time: " + cost); } static double cost (double[] taskTimes, int[] partition, int numProcessors, boolean printIt) { // Check whether too many processors were assigned. if (partition.length > numProcessors) { System.out.println ("ERROR: partition length=" + partition.length + " larger than numProcessors=" + numProcessors); System.exit(1); } // Print partition. if (printIt) { System.out.print ("Partition: "); for (int i=0; i