Suppose you have an IntegerList class that is an ordered mutable collection of (not-necessarily-unique) integers. Suppose it has only the following methods:
void cons(int x) //adds x to the front of this list int first() //returns the first integer in this list int second() //returns the second integer in this list int third() //returns the third integer in this list int nth(int n) //returns the n-th integer in this list IntegerList rest() //returns a new list identical to this list // except that the first integer of this list is omitted int size() //returns the length of the list (number of elements)
Assume that first, second, third, and nth, respectively, throw an Exception if there is no first, second, third, or n-th integer, respectively, in the list.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.