1. (30 points) Write JUnit test cases for the following list methods:
(a) A method cutTo that takes an integer and makes the list no longer than this value. If the list is initially longer than the desired length, the method removes values from the end to reduce the length. If the list is initially the desired length or shorter, the method has no eﬀect. (b) A method addIfNew that takes a value and an index. The method adds that value so that it has that index unless the value is already in that position, in which case the method does nothing. Thus, calling it with arguments “hi” and 1 on the list (“hello”, “hi”, “bye”) does nothing, but calling it with “greetings” and 1 on the same list changes the list to (“hello”, “greetings”, “hi”, “bye”). The index can cause the value to become the new last value in the list. If the index is invalid, the method should throw an IndexOutOfBoundsException. (c) A method moveToHead that takes an index. It should move the value at that index to the head of the list. For example, calling it with argument 2 on the list (“a”, “b”, “c”, “d”) changes the list to (“c”, “a”, “b”, “d”). If the index is invalid, the method should throw an IndexOutOfBoundsException.
2. (30 points) Implement each of the methods above for an array-based list.
3. (30 points) Implement each of the methods from problem 1 for a linked-memory list implementation.