Instructions
Java Program:
import java.io.*;
import java.util.LinkedList;
public class Linked_List
{
public static void main(String[] args)//Main Function
{
System.out.println();
System.out.println("IMPLEMENTATION OF LINKED LIST");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println();
System.out.println("Creating the Linked List...");
LinkedList list=new LinkedList();
System.out.println();
System.out.println("Inserting the Elements of the First 30 Perfect
Square Numbers...");
System.out.println();
list.add("1");
list.add("4");
list.add("9");
list.add("16");
list.add("25");
list.add("36");
list.add("49");
list.add("64");
list.add("81");
list.add("100");
list.add("121");
list.add("144");
list.add("169");
list.add("196");
list.add("225");
list.add("256");
list.add("289");
list.add("324");
list.add("361");
list.add("400");
list.add("441");
list.add("484");
list.add("529");
list.add("576");
list.add("625");
list.add("676");
list.add("729");
list.add("784");
list.add("841");
list.add("900");
System.out.println("The Linked List is as follows...");
System.out.println();
System.out.println(list);//Print the Linked List
System.out.println();
System.out.println("The Size of the Current Linked List is
"+list.size());
System.out.println();
System.out.println("Deleting 25, 36, 64, 100 and 400 from the
Linked List...");
System.out.println();
list.remove("25");
list.remove("36");
list.remove("64");
list.remove("100");
list.remove("400");
System.out.println("The Updated Linked List is as
follows...");
System.out.println();
System.out.println(list);//Print the Updated Linked List
System.out.println();
System.out.println("The Size of the Current Linked List is
"+list.size());
System.out.println();
System.out.println("Inserting the Element 0 as the First Element to
the Linked List...");
System.out.println();
list.addFirst("0");
System.out.println("Returning the Elements from Index 0 to Index 5
of the Linked List...");
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(0));
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(1));
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(2));
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(3));
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(4));
System.out.println();
System.out.println("The Element Returned by Index 0 is
"+list.get(5));
System.out.println();
System.out.println("The Final Updated Linked List is as
follows...");
System.out.println(list);//Print the Updated Linked List
}
}
please explain how to code using java -. Implement the ListNode and LinkedIntList as we did...
NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT WOULD CAUSE THE HW1.java TO PRINT THE RIGHT DATA.!!! The LinkedList class implements both the List interface and the Stack interface, but several methods (listed below) are missing bodies. Write the code so it works correctly. You should submit one file, LinkedList.java. Do not change the interfaces. Do not change the public method headers. Do not rename the LinkedList class. None of your methods...
Doubly Linked List Java Help Details: First, read the DoublyLinkedList.java code and try to understand what each field stores and what each method is doing. Modify and complete the class as described below •The field size was defined in the class but was never maintained. Set the current default value and modify it whenever it is needed in the existing methods and other methods you implement as it is needed. It should always include the number of Nodes inside the...
Please use Java programming: Modify both ArrayList and LinkedList classes and add the following method to both classes: public void reverseThisList(), This method will reverse the lists. When testing the method: print out the original list, call the new method, then print out the list again ------------------------------------------------------------------------- //ARRAY LIST class: public class ArrayList<E> implements List<E> { /** Array of elements in this List. */ private E[] data; /** Number of elements currently in this List. */ private int size; /**...
C++ Implement a templated class list and listnode. You may add methods/functions as you see fit. Test these classes. I have left all of the implementation as an exercise for you. template< class NODETYPE > class List; // forward declaration template<class NODETYPE> class ListNode { friend class List< NODETYPE >; // make List a friend public: ListNode( const NODETYPE &newData); // copy constructor NODETYPE getData() const; // return data in the node private: NODETYPE data; // data ListNode< NODETYPE > *nextPtr; // next node...
if we have following List classes: public class LinkedList<T> { class ListNode { protected T value; protected ListNode next; public ListNode(T val, ListNode nxt) { value = val; next = nxt; } public ListNode(T val) { this(val, null); } public ListNode() { this(null, null); } } can you write the folowing methods in java: 1.Write a method for the LinkedList class called int indexOf(T val) which returns the integer index indicating the location of val in the list, or -1...
CSBP 319 Data structures - Linked Lists - USE JAVA (NetBeans) A company would like to implement its inventory of computing machines as a linked list, called ComputerList. Write a Computer node class, called ComputerNode, to hold the following information about a Computer: • code (as a String) • brand (as a String) • model (as a String) • price (as double) • quantity (as int) ComputerNode should have constructors and methods (getters, setters, and toString()) to manage the above...
I need help and have to get this done asap: Using the following source codes provided below, create recursive functions and methods in C++ to complete the following exercises: Print the list in forward order Print the list in reverse order Print the following three lines (in this order): "The first node contains <value in first node>" "The last node contains <value in last node>" "The first node contains <value in first node>" Print the sum of all the values...
C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...
C++ Assignment Project 1 - NodeList Building upon the the ListNode/List code I would like you to extend the interface of a list to have these member functions as well. struct ListNode { int element; ListNode *next; } Write a function to concatenate two linked lists. Given lists l1 = (2, 3, 1)and l2 = (4, 5), after return from l1.concatenate(l2)the list l1should be changed to be l1 = (2, 3, 1, 4, 5). Your function should not change l2and...
Must be written and C, and compile with MinGW. Thank you! am Specification For this assignment, you will write a multi-file C program to define, implement and use a dynamic linked lists. Please refer to Lab 07 for the definition of a basic linked list. In this assignment you will need to use the basic ideas of a node and of a linked list of nodes to implement a suit of functions which can be used to create and maintain...