Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Task 1 : Linked List and Node Implementation Implement a general linked list class with a parameterized type for the data item. Here is a
Task : Linked List and Node Implementation Implement a general linked list class with a parameterized type for the data item. Here is a start of LinkedList.java: public class LinkedList head; protected int size; public LinkedList head null; size ; public void addToFrontT item public void addToBackT item public void removeint index public T getint index public void clear public int size @Override public String toString String result ; if head null return result; for Node p head; p null; p pgetNext result pgetItem ; return result.substringresult.length; remove last What is the type of head? It must refer to a Node that contains an instance variable to hold a data item of type T and a next value of type Node. Here is the start of Node.java: Fill in the missing pieces in these two classes, and test them with main method, either in LinkedList.java or in a new file named something like TestLL.java, that looks like this. Note that you need to implement the Node class that consists of two variables string item and a Node next object.
Task : Linked List and Node Implementation
Implement a general linked list class with a parameterized type for the data item. Here is a start of LinkedList.java:
public class LinkedList
head;
protected int size;
public LinkedList
head null;
size ;
public void addToFrontT item
public void addToBackT item
public void removeint index
public T getint index
public void clear
public int size
@Override
public String toString
String result ;
if head null
return result;
for Node p head; p null; p pgetNext
result pgetItem
;
return result.substringresult.length; remove last
What is the type of head? It must refer to a Node that contains an instance variable to hold a data item of type T and a next value of type Node. Here is the start of Node.java:
Fill in the missing pieces in these two classes, and test them with main method, either in LinkedList.java or in a new file named something like TestLL.java, that looks like this.
Note that you need to implement the Node class that consists of two variables string item and a Node next object.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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