
- Node class
4. stuID, stuName, stuScore, //data fields
5. constructor
6. update and accessor methods
- Singly linked list class which must has following methods:
4. head, tail, size// data fields
5. constructor
6. update and accessor methods
a. getSize() //Returns the number of elements in the list.
b. isEmpty( ) //Returns true if the list is empty, and false otherwise.
c. getFirstStuID( ), getStuName( ), getFirstStuScore( )
d. addFirst (stuID, stuName, stuScore)
e. addLast(stuID, stuName, stuScore)
f. removeFirst( ) //Removes and returns the first element of the list.
g. removeLast( ) //Removes and returns the first element of the list.
h. displayList( ) //Displays all elements of the list by traversing the linked list.
- Test class – initialize a doubly linked list instance. Test all methods of doubly linked list class.

- Node.java
1. Create a Node class with the following attributes:
- int stuID
- String stuName
- double stuScore
- Node next (points to the next node)
- Node prev (points to the previous node)
2. Create a constructor for the Node class to initialize stuID, stuName, stuScore, next, and prev.
- DoublyLinkedList.java
1. Create a DoublyLinkedList class with the following attributes:
- Node head (points to the first node)
- Node tail (points to the last node)
- int size (stores the number of elements in the list)
2. Create a constructor for the DoublyLinkedList class to initialize head, tail, and size.
3. Implement the following methods:
- getSize(): Returns the number of elements in the list.
- isEmpty(): Returns true if the list is empty; otherwise, returns false.
- getFirstStuID(): Returns the student ID of the first student in the list.
- getStuName(): Returns the student name of the first student in the list.
- getFirstStuScore(): Returns the student score of the first student in the list.
- addFirst(stuID, stuName, stuScore): Adds a student at the beginning of the list.
- addLast(stuID, stuName, stuScore): Adds a student at the end of the list.
- removeFirst(): Removes and returns the first student in the list.
- removeLast(): Removes and returns the last student in the list.
- displayList(): Displays all elements in the list.
4. Implement the addFirst and addLast methods to create a new Node and update the head, tail, and size accordingly.
5. Implement the removeFirst and removeLast methods to remove a student Node from the list and update head, tail, and size accordingly.
6. Implement displayList to iterate through the list and print student information.
- TestDoublyLinkedList.java
1. Create a DoublyLinkedList instance called studentList.
2. Use the various methods of the DoublyLinkedList class to add, retrieve, and remove students from the list.
3. Print the results and verify that the doubly linked list operations are working correctly.
Step by stepSolved in 4 steps with 7 images

- Write a program in Java to manipulate a Singly Linked List: Count the number of nodes Insert a new node before the value 5 of Singly Linked List Search an existing element in a Singly linked list (the element of search is given by the user) Suppose List contained the following Test Data: Input data for node 1: 2Input data for node 2 : 3Input data for node 3 : 5 Input data for node 4: 8arrow_forwardData Structures/Algorithms in Javaarrow_forwardJava Given main() in the ShoppingList class, define an insertAtEnd() method in the ItemNode class that adds an element to the end of a linked list. DO NOT print the dummy head node. Ex. if the input is: 4 Kale Lettuce Carrots Peanuts where 4 is the number of items to be inserted; Kale, Lettuce, Carrots, Peanuts are the names of the items to be added at the end of the list. The output is: Kale Lettuce Carrots Peanuts Second image is ItemNodearrow_forward
- JavaScript Given a singly linked list of integers, determine whether or not it's a palindrome. // Singly-linked lists are already defined with this interface: // function ListNode(x) { // this.value = x; // this.next = null; // } // function isListPalindrome(head) { } Note: in examples below and tests preview linked lists are presented as arrays just for simplicity of visualization: in real data you will be given a head node l of the linked list Example For l = [0, 1, 0], the output should beisListPalindrome(l) = true; For l = [1, 2, 2, 3], the output should beisListPalindrome(l) = false.arrow_forwardIn Java please help with the following: Sees whether this list is empty.@return True if the list is empty, or false if not. */ public boolean isEmpty(); } // end ListInterface Hint:Node class definition should look something like: public class Node<T> { T element; Node next; Node prev; public Node(T element, Node next, Node prev) { this.element = element;this.next = next;this.prev = prev; } }arrow_forwardInstruction: To test the Linked List class, create a new Java class with the main method, generate Linked List using Integer and check whether all methods do what they’re supposed to do. A sample Java class with main method is provided below including output generated. If you encounter errors, note them and try to correct the codes. Post the changes in your code, if any. Additional Instruction: Linked List is a part of the Collection framework present in java.util package, however, to be able to check the complexity of Linked List operations, we can recode the data structure based on Java Documentation https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html package com.linkedlist; public class linkedListTester { public static void main(String[] args) { ListI<Integer> list = new LinkedList<Integer>(); int n=10; for(int i=0;i<n;i++) { list.addFirst(i); } for(int…arrow_forward
- Given the interface of the Linked-List struct Node{ int data; Node* next = nullptr; }; class LinkedList{ private: Node* head; Node* tail; public: display_at(int pos) const; ... }; Write a definition for a method display_at. The method takes as a parameter integer that indicates the node's position which data you need to display. Example: list: 5 -> 8 -> 3 -> 10 display_at(1); // will display 5 display_at(4); // will display 10 void LinkedList::display_at(int pos) const{ // your code will go here }arrow_forwardIN PYTHON THANK YOUarrow_forwardThis is using Data Structures in Javaarrow_forward
- IN JAVA PLEASE, need help finding an element in the list /** * Returns whether the given value exists in the list. * @param value - value to be searched. * @return true if specified value is present in the list, false otherwise. */ public int indexOf(int value) { //Implement this method return -1; }arrow_forwardWrite a program in Java to manipulate a Double Linked List: Count the number of nodes Insert a new node before the value 7 of Double Linked List Search an existing element in a Double linked list (the element of search is given by the user) Suppose List contained the following Test Data: Input the number of nodes : 4Input data for node 1 : 5Input data for node 2 : 6 Input data for node 3 : 7 Input data for node 4: 9arrow_forwardThe tail of a linked list is distinguished from other nodes because its next pointer is:A. void B. empty C. NULL D. None of the above.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





