help me complete the add method
help me finish the add(int index, E value)method on handwritten linked list. The code in the attatchment
Add a method void add(int index, E value) which adds a new node at the indexth spot in list
The algorithm is the following:
- create a new node with value in it
- if head is null, the list is empty, so just set head and tail to the new node
- If head is not null, loop to the node in front of where you want to put the new node (see toString() for a model of looping through a linked list). Then set the new node’s next pointer to the next node ahead, and the previous node’s next pointer to the new node. Reassign tail if necessary.