Question
Complete the implementation of a List ADT using linked nodes In this lab, you are going to play a role as an ADT programmer again
Complete the implementation of a List ADT using linked nodes In this lab, you are going to play a role as an ADT programmer again to finish implementing a list ADT using linked node. Recall the data structure of linked lists 32 ->987-> 42-> 77-> 135 5 List The List interface has been provided as List.java. Given this interface, the application programmer has developed a simple application TestList.java to use the List ADT. Your task for todays lab is to fill in the three operations/methods in the List ADT: public void insertHead(E item) public void insertTail(E item) public void insertAtPosition (E item, int position) A backbone of the ADT is provided in BasicLinkedList.java. You will need to fill in the code in each of the three methods. 1
/** * Defines the interface to a list collection. * The implementation of the list is hidden. * */ public interface List
/** Insert a new node to the head of the list. Pre: item :: E, content in the new node Post: new node is inserted to the head of the list Return: nothing */ public void insertHead(E item); /** Insert a new node to the end of the list. Pre: item :: E, content in the new node Post: new node is inserted to the end of the list Return: nothing */ public void insertTail(E item); /** Insert a new node at a specific position in the list. Pre: item :: E, content in the new node position :: the position of the new node Post: new node is inserted at position in the list Return: nothing */ public void insertAtPosition (E item, int position); /** Retrive the element at a specific position in the list. Pre: position :: Integer, a position in the list Post: the list is unchanged Return: the element at the position */ public E get(int position); /** * Useful method for pretty print Pre: Post: the list is unchanged. Return: Returns a string representation of this list. */ public String toString()}
2.public class TestList { public static void main(String[] args) { List
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started