Explanation of Solution
Modified definition of “ListNode” class in Listing 12.4:
The modified definition of “ListNode” class in Listing 12.4 is given below:
//Define class "ListNode2"
public class ListNode2<E>
{
//Declare variable "data" and "link" in type parameter
private E data;
private ListNode2<E> link;
//Create default constructor for "ListNode2"
public ListNode2()
{
link = null;
data = null;
}
/* Create parameterized constructor for "ListNode2" */
public ListNode2(E newData, ListNode2<E> linkValue)
{
/* Assign value to "data" and "link" */
data = newData;
link = linkValue;
}
//Accessor method for assign value to data
public void setData(E newData)
{
data = newData;
}
//Mutator method for return data
public E getData( )
{
;&#x...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Java Format: Unbound (saleable)
- Create code that will find duplicate keys in a linked list and remove them all.arrow_forwardIn Kotlin, Create a list that uses your area function as an initializer and contains the areas of circles with each integer from 1 to 25 as radius.arrow_forwardWhich methods from the List interface are not supported by ArrayList and LinkedList? Explain why you think such methods aren't a part of List.arrow_forward
- Which methods do ArrayList and LinkedList have that are not defined in the List interface? Why do you think that these methods are not included in List?arrow_forwardYou are going to implement a program that creates an unsorted list by using a linked list implemented by yourself. NOT allowed to use LinkedList class or any other classes that offers list functions. It is REQUIRED to use an ItemType class and a NodeType struct to solve this homework. The “data.txt” file has three lines of data 100, 110, 120, 130, 140, 150, 160 100, 130, 160 1@0, 2@3, 3@END You need to 1. create an empty unsorted list 2. add the numbers from the first line to list using putItem() function. Then print all the current keys to command line in one line using printAll(). 3. delete the numbers given by the second line in the list by using deleteItem() function. Then print all the current keys to command line in one line using printAll().. 4. putItem () the numbers in the third line of the data file to the corresponding location in the list. For example, 1@0 means adding number 1 at position 0 of the list. Then print all the current keys to command line in one…arrow_forwardFor this assignment I want you to create a linked list that can store generics. This work NEED JAVA FILE, it is one java program. You will need to complete the following files: insertEnd - This method is like insertFront except the item goes at the end of the list, not the beginning removeLast - This method is like the remove method, except it removes that last occurrence of the item removeAll - This method remove all items that match the provided item previous - The method returns the node in front of the item findAndMoveToFront - The method returns the first node containing the item, but as a side effect it also moves that node to the first of the list. This potentially makes future searches faster. This is called the move to front search heuristic.arrow_forward
- What are the differences between ArrayList and Vector? Which collection class is good for manipulatingdata?arrow_forwardStudy the code below: public __________ ____________() { MyLinkedList newlist = new MyLinkedList<>(); for(Node ptr=head;ptr!=null;ptr=ptr.next) { newlist.prepend(ptr.element); } return newlist; } What is the purpose of the codearrow_forwardWhich accesses the number of elements in groceryList? ArrayList <String> groceryList;groceryList = new ArrayList<String>(); A. groceryList.size B. groceryList.length C. groceryList.length( ) D. groceryList.size( )arrow_forward
- In java, how do I implement the following methods into a linkedlist class. 1) removeLast() – remove the last number of the list 2) removeLeast()- remove least number in the list 3) removeMax()- remove largest number in the list 4) removeFirst() – remove the first number of the list 5) addNum()- add another number to the listarrow_forwardWrite a program that creates an ArrayList and adds a Loanobject, a Date object, a string, and a Circle object to the list, and use a loop todisplay all the elements in the list by invoking the object’s toString() method.arrow_forwardCreate a new Hash class that uses an arraylist instead of an array for the hash table. Test your implementation by rewriting (yet again) the computer terms glossary application.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education