COP 3530 Section 1 EXAM 1 February 28, 2000 Kraynek Name:_______________ 10 points 1. Consider the following Java declarations. Object O; Integer I = new Integer(37); List aList; ArrayList A = new ArrayList(); In the following segment, which of the following statements will not compile and which will cause a runtime error. O = I; I = O; I = (Integer)O; O = new String("37"); I = (Integer)O; aList = new List(); aList = A; aList = new HashSet(); 10 points 2. Which function grows faster, n*log(n)2 or (n2)*log(n)? 10 points 3. Solve the following recurrence equation: R(0) = 1 R(n) = 3*R(n-1) + 1 10 points 4. What is the running time of the following method? public static int numZeros(int[] A, int left, int right) { if( left > right) return 0; int middle = (left+right)/2; return numZeros(A,left,middle-1) + numZeros(A,middle+1,right) + (A[middle]==0?1:0); } 35 points 5. Write a Java class (program) that reads the NCAA data as in Assignment Four and outputs to a file each year the tournament was played in order along with each team that won a game that year. Make sure each team appears only once. Use BufferedReader in = new BufferedReader(new FileReader("ncaa99.data")); PrintWriter out = new PrintWriter(new FileWriter("ncaayearname.txt"),true); to open the input and output files. 25 points 6. Write the method public static List getWords(ArrayList A); that puts the unique unsorted Strings (words) from the ArrayList A into a LinkedList in sorted order and return the LinkedList.