Task 2 ------ 1-2. See separate ListClient.java file. 3. If we pass an ArrayList into contains(), each iteration of the loop calls the ArrayList version of getItem() to get the item at position i. Because arrays have random access, this version of getItem() takes a constant number (O(1)) of steps to get the item at position i for any value of i. Therefore: - The best case is O(1), when we find the item at the beginning of the list and only perform one iteration of the loop before returning. - The worst case is O(n), when we either find the item at the end of the list or never find it. In either case, we perform all n iterations, and each iteration performs a constant number of operations. - The average case is also O(n), because on average we perform half of the iterations of the loop, each of which performs a constant number of operations. If we pass an LLList into contains(), each iteration of the loop calls the LLList version of getItem() to get the item at position i. This version of getItem() calls getNode(i), which starts at the beginning of the linked list and walks down to the node at position i. As a result, it takes O(i) steps to get the item at position i. Therefore: - The best case is O(1), when we find the item at the beginning of the list and only perform one iteration of the loop before returning. This iteration calls list.getItem(0), and because item 0's node is at the beginning of the linked list, it takes only a small, fixed number of steps to access it. - The worst case is O(n^2), when we either find the item at the end of the list or never find it. In either case, we perform all n iterations, and each iteration performs O(i) steps. Thus, the total number of steps is proportional to the sum of the arithmetic sequence 1 + 2 + 3 + ... + n = O(n^2). - The average case is also O(n^2), because on average we perform half of the iterations of the loop, which means we still get a total number of steps that is roughly proportional to n^2. 4. To make contains() efficient for both ArrayList objects and LLList objects, we need to rewrite it to use an iterator. See contains2() in ListClient.java.