#1 A. O(N^3) or N^3 B. O(NlogN) or NlogN base //base 2 included okay C. O(N^2) or N^2 D. O(1) or 1 or constant ot constant time E. O(N) or N, N = number of items in list F. O(N) or N, N = number of items in list G. 0 1 3 7 15 H. 27 I. O(2^N) or 2^N J. runtime error or error or syntax error or 13 or unknown or Exception K. O(logN) or logN // base 2 included okay L. 5000 M. 128 seconds or 128 //2 * 4000 ^ 3 / 1000 ^ 3 okay N. anything between 14 and 15 inclusive O. 23 17 45 81 96 79 52 48 70 94 74 67 order among sublists irrelevant #2 Model Solution Object data = myHead.getData(); myHead = myHead.getNext(); if(iMySize == 1) myTail = null; iMySize--; return data; #3 Model Solution if( (toIndex - fromIndex) > 0 ) { int destIndex = fromIndex; int sourceIndex = toIndex; // shift items for(; sourceIndex < iMySize; sourceIndex++, destIndex++) myCon[destIndex = myCon[sourceIndex]; // null out new empty elements for(; destIndex < iMySize; destIndex++) myCon[destIndex = null]; iMySize = iMySize - (toIndex - fromIndex); } # 4 Model Solution Random rand = new Random(); Object temp; int randIndex = 0; for(int i = 0; i < data.size(); i++) { randIndex = rand.nextInt( data.size() ); temp = data.get(i); data.set(i, data.get(randIndex) ); data.set(randIndex, temp); } #4 criteria -0 any minor syntax error or syntax errors where intent is clear -3 Random Object not created (Random.nextInt() common and wrong) -2 [] for access to ArrayList items -7 algorithm is worse than O(N) -3 using methods from ArrayList that were not allowed (allowable methods listed on test) especially ArrayLIst constructor, ArrayList temp = new ArrayList(); -7 does not truly shuffle data -3 does not use data parameter, assumes method is in arraylist class. -3 other major logic error -1 other minor logic error #5 Model Solution return helper(orig, destAir, new ArrayList() ); } private boolean helper(Airline org, Airline dest, ArrayList tried) { // base case success if( org.equals(dest)) return true; // base case failure if( tried.contains(org) ) return false; // recursive step tried.add(org) ArrayList parts = org.partners(); for(int i = 0; i < parts.size(); i++) { if( helper( (Airline)(parts.get(i)), dest, tried) return true; // could remove from tried, but not necessary for this question } // tried everything and failed return false; } #5 Criteria -3 early return, should only return if true return milesHelper( blah ); // in for loop, wrong if( milesHelper() ) return true; // right -8 no attempt to stop infinite recursion -4 attempts, but fails to prevent infinite recursion -3 using == or != with Airline objects instead of .equals -5 does not loops through partners of original or other current airline -8 no attempt at recursion, tries to use other classes (stacks, queues) -3 other major logic error -1 other minor logic error