List Implementation
In this week’s labs, you’ll implement the list abstract data type in two ways: arrays and links. Fork the repository found here to your Github account:
Clone your copy of the repository to your computer and complete the basic implementation of the ArrayList and LinkedList classes.
This includes filling out all the basic list methods found in each class.
Add appropriate Javadoc comments to each method.
In addition to including relevant @param and @returns tags, also include the worst case runtime of the method in Big-O notation.
Check with a member of the course staff after you complete each method, and they will verify your runtime.
Additionally, complete the test suite for each of the classes (ArrayListTests.java and LinkedListTests.java, respectively).
To do this, make sure to write unit tests that cover normal-case and base-case scenarios for each method.
Also, write at least one additional property-based tests for each of your list implementations.
(Hint: the two list implementations share the same set of methods, so they can probably share the same tests…!)
Additional practice
Once you complete your basic list implementation, feel free to implement the following methods for additional practice working with array-based and linked-based lists.
Extended Basic List Methods
boolean isEmpty(): returnstrueif and only if the list has no elements.void clear(): removes all the elements from the list.int indexOf(int value): returns the index of the first occurrence ofvaluein the list or-1ifvalueis not in the list.boolean contains(int value): returnstrueif and only ifvalueis found in the list.void add(int index, int value): addsvalueto the list atindex, throwing anIndexOutOfBoundsExceptionifindexis out of range (index < 0 || index > size()).
Advanced Operations
Want even more practice with list operations? Try implementing the following methods:
String toString(): returns a string representation of the list in the form"[x1, x2, x3, ...]".boolean equals(ArrayList other)andboolean equals(LinkedList other): returnstrueif thislistis equal toother, i.e., they contain exactly the same elements in the same order.ArrayList concat(ArrayList other)andLinkedList concat(LinkedList other): returns a new list that contains the elements of this list and the elements of theotherlist.