/* Data Structures & Algorithms Algorithm 1 Oct 11,2001 Bruce West, Michael Jones, Hugo Vo, Joan Julius */ public class CubicAlgorithm { static int[] inArray; static int[] bentley = {31,-41,59,26,-53,58,97,-93,-23,84}; static int[] newTestData = {1,1,1,1,1,-1,-1,-1,-1,-1,10,11, -1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1, 1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1, 1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1, 1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,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,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1, 1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1}; // static int arraySize; public static void main (String argv[] ) { int startNbr = 10; // int arraySize = Integer.parseInt( argv[0] ); // debug // System.out.println ("we've parsed the incoming string " + arraySize ); //end debug // int x; // { // for (x = 0; x < 12; x++) // { startNbr = startNbr + 2; // inArray[x] = startNbr;} // System.out.println ("array nbrs: " + startNbr); // } int nbrElements = 0; { for (int i = 0; i < newTestData.length; i++) nbrElements = nbrElements + 1; } System.out.println (" Number of elements in our array: " + nbrElements ); System.out.println (); long startTime = System.currentTimeMillis(); System.out.println (" Start Time: " + startTime); System.out.println("Highest positive value: " + Algorithm1.maxSegmentSum(newTestData)); // Algorithm1.maxSegmentSum(bentley)); long endTime = System.currentTimeMillis(); System.out.println (" End Time: " + endTime); System.out.println (" Elapsed Run Time in Milliseconds: " + (endTime - startTime)); // code below is to run other algorithms /* System.out.println (Algorithm2 High Value: " + Algorithm2.maxSegmentSum(bentley)); System.out.println(); System.out.println (Algorithm2b High Value: " + Algorithm2b.maxSegmentSum(bentley)); System.out.println(); System.out.println (Algorithm3 High Value: " + Algorithm3.maxSegmentSum(bentley)); System.out.println(); System.out.println (Algorithm4 High Value: " + Algorithm4.maxSegmentSum(bentley)); */ } }