Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
Write a Java program which stores three values by using doubly linked list.
- 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.
Expert Solution
Check Mark
Step 1: The algorithm

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.


Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education