4 attachmentsSlide 1 of 4attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3attachment_4attachment_4
Unformatted Attachment Preview
Using the given generic interface LinkedList.java and the generic class Node.java, create a class MyLinkedList.java which is a
generic class which implements LinkedList.java. It should contain the following attributes:
Node head – the first value of the linked list
As well as the following constructors/methods:
add(E item): void – Adds a new Node containing the item E to the end of the linked list.
add(E item, int loc): void – Adds a new Node containing the item E at the location loc, shifting the item already there
forward if necessary.
remove(E item): void – removes the first node containing a value equal to item, adjusting the order the linked list
traverses if necessary.
clear(): void – Empties the linked list entirely.
getSize(): int – returns the size of the list by traversing through the linked list.
getValue(int loc): E – returns the value of the node located at index loc.
indexOf(E item): int – returns the index of the first node that contains the value item.
rev. February 16 – 1 / 1
Purchase answer to see full
User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.