1. Suppose we are sorting ...
    1. after the third iteration of insertion sort
      527 620 884 909 32 927 276 411 322 445
    2. after the third iteration of selection sort
      32 276 322 620 884 927 909 411 527 445
    3. after the third merge in a merge sort.
      884 909 32 527 620 927 276 411 322 445
      OR
      527 884 909 32 620 927 276 411 322 445
    4. after the first iteration of radix sort.
      (SORRY! We didn't do radix sort this year!)
    5. after being 3-sorted with Shell sort (i.e. gap = 3)
      276 32 322 445 411 527 620 909 927 884
  2. Consider the following array ...
    1. Circle the values would we consider for the pivot ...
      76, 80 and 37
    2. Which of those values would we end up choosing as the pivot?
      76
    3. What position would the pivot value end up ...
      7
    4. Given the partition above, what are the bounds ...
      Lower sub-array: from index __0_ to index __6_.
      Upper sub-array: from index __8_ to index _10_.
  3. State the order of magnitude ...
    1. O(N3)
    2. O(N2)
    3. O(N3)
    4. O(N log N)
    5. O(N2)
    6. O(N4)
  4. Write the method getFrequency ...
    public int getFrequency(T item) {
        int count = 0;
        Node cur = first;
        while (cur != null) {
            if (cur.data.equals(item)) {
                ++count;
            }
            cur = cur.next;
        }
        return count;
    }
    
  5. Implement the function Q ...
    public int Q(int n) {
        if (n < 3) {
            return n;
        } else {
            return Q(n – Q(n-1)) + Q(n – Q(n-2));
        }
    }
    
  6. The following method shows a typical use ...
    public interface MyADT {
        public void showValues();
        public boolean hasZeroValue();
        public int getZeroLocation();
        public double solve(int location);
    }
    
  7. Consider the following railway switching yard.
    1. Move Move Move
    2. Move Enqueue Move Dequeue
    3. Enqueue Move Dequeue Move
    4. Enqueue Move Move Dequeue
    5. Enqueue Enqueue Move Dequeue Dequeu
    6. Cannot be done
  8. Write the definition of the generic method maxElement.
    public static <T extends <? super T>> T maxElement(T[] arr) {
        T result = arr[0];
        for (int i = 1; i <= arr.length; ++i) {
            if (result.compareTo(arr[i]) > 0) {
                result = arr[i];
            }
        }
        return result;
    }
    
  9. Use the space provided to show how the stack evolves ...
        + + /
    +
    /
    +
    *
    +
    *
    +
    -
    (
    -
    (
    -
    +
    (
    -
    +
    (
    -
    - -  
    1 2 3 / 4 * + 5 6 + - 7 +
  10. Multiple Choice: