Exercise

  • Implement IndexedList operations with a (singly) linked list implementation (LinkedIndexedList).

Open the starter code and look for the LinkedIndexedList.java file. This file is a linked list implementation of IndexedList ADT.

Exercise Complete the implementation of LinkedIndexedList (at home!)

Note here we cannot start with an empty list. Instead, we must build a complete list (with the given size and the default value) in the LinkedIndexedList constructor.

We have written our unit tests based on the specification of the IndexedList ADT. Therefore, we can use the same suite of tests to test both implementations of IndexedList (that is ArrayIndexedList and LinkedIndexedList). We need to switch between these two implementations. Open the starter code and find out how this is done by leveraging inheritance. (Hint: look for the abstract method createUnit).

Solution

Refer to the solution code posted.