PLEASE SOLVE IN JAVA. I can only fit the entire problem by having the driver code as an image but since there's a picture limit also I had to trim the output so it would nearly fit. THANK YOU IN ADVANCE      public class DoublyLinkedList { // define ListNode elements specific for this type of list, indicating current, previous and next // consider head as name for previous node, and tail for the next one. private ListNode head; private ListNode current; private ListNode tail; // default constructor public DoublyLinkedList() { //*** Task #1: implement a default constructor here, initializing the nodes to null } // method that calculates the length of the list public int length() { //*** Task #2: implement the method navigating through the list until you run out of elements } // method that adds a node at the beginning of the list public void addANodeToStart(E addData) { //*** Task #3: implement this method, taking into consideration that the head will be replaced by a new node. You may want to use a temporary variable } // accessor method that gets data at current node public E getDataAtCurrent() { //*** Task #4: implement this method making sure to take into account the situation when // there current doesn't point to any data (is null) } // method that sets the current node in the beginning, reseting the iteration public void resetIteration() { //*** Task #5: implement the body of the method } // method that checks if there is more to interate in the list public boolean moreToIterate() { //*** Task #6: implement the body of the method } // method that moves the node to the next position, if possible public void goToNext() { //*** Task #7: implement the method taking into account the situation when the list is empty // check if there are other instances when the move is not possible. } // method that resets the reverse iteration, setting the current node to the last one public void resetIterationReverse() { //*** Task #8: implement the body of the method } // method that facilitates the move in the reverse directions, redirecting the node to previous public void goToPrevious() { //*** Task #9: implement this method in a similar way the goToNext() method // make sure to have the right links for the reverse navigations } /* Method that inserts node with newData after the current node. Note: The current node is the same after invocation as it is before invocation. Should not be used with an empty list. Should not be used when the current node has iterated past the entire list. */ public void insertNodeAfterCurrent(E newData) { //*** Task #10: implement this method, making sure to observe the ideas noted above } /* Method that deletes the current node. After the invocation, the current node is the node after the deleted node or null if there is no next node. */ public void deleteCurrentNode() { //*** Task #11: implement this method, making sure to observe the ideas noted above } // method that deletes the head node. public void deleteHeadNode() { //*** Task #12: implement this method } // Searches list for element containing target data. // If target is found, current is set to point at it, // and the function returns true. // If target is not found, current is set to null // and the function returns false. public boolean findInList(E target) { //*** Task #13: implement this method, making sure to observe the ideas noted above } public boolean onList(E target) { //*** Task #14: implement this method } private ListNode Find(E target) { //*** Task #15: implement this method } // meethod that displays the list public void showList() { //*** Task #16: irrespective of navigation through the list, the display remains the same // start from the head and move through the list to show all elements. } // Method useful during testing and debugging, that allows control over the nodes. public void showListState() { System.out.println("Head: " + (head == null ? "null" : head.data) + " Current: " + (current == null ? "null" : current.data) + " Tail: " + (tail == null ? "null" : tail.data) + " " + length() + " items"); }   // inner class for ListNode public class ListNode { // instance variables private E data; private ListNode link; private ListNode previous; // constructor - default public ListNode() { //*** Task #17: implement this constructor } // constructor, fully defining the list public ListNode(E newData, ListNode linkValue, ListNode previousValue) { //*** Task #18: implement this constructor } // mutator for data public void setData(E newData) { //*** Task #19: implement this method } // accessor for data public E getData() { //*** Task #20: implement this method } // mutator for the node public void setLink(ListNode newLink) { //*** Task #21: implement this method } // mutator for the previous node public void setPrevious(ListNode newPrevious) { //*** Task #22: implement this method } // accessor for the current node public ListNode getLink() { //*** Task #23: implement this method } // accessor for the previous node public ListNode getPrevious() { //*** Task #24: implement this method } } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PLEASE SOLVE IN JAVA. I can only fit the entire problem by having the driver code as an image but since there's a picture limit also I had to trim the output so it would nearly fit. THANK YOU IN ADVANCE 

 

 

public class DoublyLinkedList<E>
{
// define ListNode elements specific for this type of list, indicating current, previous and next
// consider head as name for previous node, and tail for the next one.
private ListNode<E> head;
private ListNode<E> current;
private ListNode<E> tail;

// default constructor
public DoublyLinkedList()
{
//*** Task #1: implement a default constructor here, initializing the nodes to null

}

// method that calculates the length of the list
public int length()
{
//*** Task #2: implement the method navigating through the list until you run out of elements

}

// method that adds a node at the beginning of the list
public void addANodeToStart(E addData)
{
//*** Task #3: implement this method, taking into consideration that the head will be replaced by a new node. You may want to use a temporary variable

}

// accessor method that gets data at current node
public E getDataAtCurrent()
{
//*** Task #4: implement this method making sure to take into account the situation when
// there current doesn't point to any data (is null)

}

// method that sets the current node in the beginning, reseting the iteration
public void resetIteration()
{
//*** Task #5: implement the body of the method
}

// method that checks if there is more to interate in the list
public boolean moreToIterate()
{
//*** Task #6: implement the body of the method
}

// method that moves the node to the next position, if possible
public void goToNext()
{
//*** Task #7: implement the method taking into account the situation when the list is empty
// check if there are other instances when the move is not possible.

}

// method that resets the reverse iteration, setting the current node to the last one
public void resetIterationReverse()
{
//*** Task #8: implement the body of the method
}

// method that facilitates the move in the reverse directions, redirecting the node to previous
public void goToPrevious()
{
//*** Task #9: implement this method in a similar way the goToNext() method
// make sure to have the right links for the reverse navigations
}

/*
Method that inserts node with newData after the current node.
Note: The current node is the same after invocation as it is before invocation.
Should not be used with an empty list.
Should not be used when the current node has iterated past the entire list.
*/
public void insertNodeAfterCurrent(E newData)
{
//*** Task #10: implement this method, making sure to observe the ideas noted above
}

/*
Method that deletes the current node. After the invocation,
the current node is the node after the
deleted node or null if there is no next node.
*/
public void deleteCurrentNode()
{
//*** Task #11: implement this method, making sure to observe the ideas noted above
}

// method that deletes the head node.
public void deleteHeadNode()
{
//*** Task #12: implement this method

}

// Searches list for element containing target data.
// If target is found, current is set to point at it,
// and the function returns true.
// If target is not found, current is set to null
// and the function returns false.
public boolean findInList(E target)
{
//*** Task #13: implement this method, making sure to observe the ideas noted above

}

public boolean onList(E target)
{
//*** Task #14: implement this method
}

private ListNode<E> Find(E target)
{
//*** Task #15: implement this method
}

// meethod that displays the list
public void showList()
{
//*** Task #16: irrespective of navigation through the list, the display remains the same
// start from the head and move through the list to show all elements.
}

// Method useful during testing and debugging, that allows control over the nodes.
public void showListState()
{
System.out.println("Head: " + (head == null ? "null" : head.data)
+ " Current: " + (current == null ? "null" : current.data)
+ " Tail: " + (tail == null ? "null" : tail.data)
+ " " + length() + " items");
}

 

// inner class for ListNode
public class ListNode<E>
{
// instance variables
private E data;
private ListNode<E> link;
private ListNode<E> previous;
// constructor - default
public ListNode()
{
//*** Task #17: implement this constructor
}
// constructor, fully defining the list
public ListNode(E newData, ListNode<E> linkValue, ListNode<E> previousValue)
{
//*** Task #18: implement this constructor
}
// mutator for data
public void setData(E newData)
{
//*** Task #19: implement this method
}
// accessor for data
public E getData()
{
//*** Task #20: implement this method
}
// mutator for the node
public void setLink(ListNode<E> newLink)
{
//*** Task #21: implement this method
}
// mutator for the previous node
public void setPrevious(ListNode<E> newPrevious)
{
//*** Task #22: implement this method
}
// accessor for the current node
public ListNode<E> getLink()
{
//*** Task #23: implement this method
}
// accessor for the previous node
public ListNode<E> getPrevious()
{
//*** Task #24: implement this method
}
}
}

Your Tasks

1. **Class Definition for Doubly Linked List:**
   - Write a class definition for a doubly linked list using a data type of your choice, such as String. If you have a class, like Student, from previous assignments, feel free to use it.

2. **Modify Node Class:**
   - Modify the Node class to integrate the doubly linked list and make it an inner class.

3. **Build the DoublyLinkedList Class:**
   - Download the `DoublyLinkedList.txt` file, which contains tasks to create an operational class for doubly linked lists.
   - Files provided:
     - [DoublyLinkedList.txt](#)
     - [DoublyLinkedListDriver.txt](#)

4. **Method Implementation:**
   - You can choose any methods for list navigation. Use the provided driver template file for guidance.

5. **Operations Guide for the Driver File:**
   - Define the doubly linked list with your desired type. Include any custom class definitions, such as Student.
   - Operations to be performed:
     - Add a node to an empty list.
     - Add one node to the end.
     - Add at least two nodes to the end.
     - Add at least one node to the middle.
     - Delete the first node.
     - Add two more nodes at the end.
     - Navigate to and delete a node in the middle.
     - Add a node at the beginning.
     - Find a specific element.
     - Display the list after operations.

6. **Display List:**
   - Ensure the list is displayed after each operation.

7. **Sample Output:**
   - Correct implementation will produce outputs like the below samples. You can also view other sample options:
     - [Sample Output Option 2](#)
     - [Sample Output Option 3](#)

   ```
   Head: null Current: null Tail: null 0 items
   =============================
   Add a node to an empty list.
   Head: CSC201 Current: CSC201 Tail: CSC201 1 items
   =============================
   Add nodes to the end of the list.
   Head: CSC201 Current: CSC202 Tail: CSC202 2 items
   Head: CSC202 Current: CSC202 Tail: CSC202 3 items
   CSC201
   CSC202
   CSC202
   =============================
   Add node to the middle of the
Transcribed Image Text:Your Tasks 1. **Class Definition for Doubly Linked List:** - Write a class definition for a doubly linked list using a data type of your choice, such as String. If you have a class, like Student, from previous assignments, feel free to use it. 2. **Modify Node Class:** - Modify the Node class to integrate the doubly linked list and make it an inner class. 3. **Build the DoublyLinkedList Class:** - Download the `DoublyLinkedList.txt` file, which contains tasks to create an operational class for doubly linked lists. - Files provided: - [DoublyLinkedList.txt](#) - [DoublyLinkedListDriver.txt](#) 4. **Method Implementation:** - You can choose any methods for list navigation. Use the provided driver template file for guidance. 5. **Operations Guide for the Driver File:** - Define the doubly linked list with your desired type. Include any custom class definitions, such as Student. - Operations to be performed: - Add a node to an empty list. - Add one node to the end. - Add at least two nodes to the end. - Add at least one node to the middle. - Delete the first node. - Add two more nodes at the end. - Navigate to and delete a node in the middle. - Add a node at the beginning. - Find a specific element. - Display the list after operations. 6. **Display List:** - Ensure the list is displayed after each operation. 7. **Sample Output:** - Correct implementation will produce outputs like the below samples. You can also view other sample options: - [Sample Output Option 2](#) - [Sample Output Option 3](#) ``` Head: null Current: null Tail: null 0 items ============================= Add a node to an empty list. Head: CSC201 Current: CSC201 Tail: CSC201 1 items ============================= Add nodes to the end of the list. Head: CSC201 Current: CSC202 Tail: CSC202 2 items Head: CSC202 Current: CSC202 Tail: CSC202 3 items CSC201 CSC202 CSC202 ============================= Add node to the middle of the
This code snippet demonstrates a framework for implementing and manipulating a doubly-linked list in Java. Here's a detailed transcription and explanation of the code:

### Code Overview

The class `DriverDoublyLinkedList_Framework` contains the `main` method, which outlines a series of tasks related to creating and manipulating a doubly-linked list. These tasks can serve as a guideline for understanding how various operations on a doubly-linked list function.

### Tasks

1. **Variable Definition**: Initialize the necessary variables for your application.
2. **Instantiation**: Create a new doubly-linked list.
3. **Display List State**: Show the current state of the list and format it for clarity.
4. **Build the List**: Add nodes to the list, demonstrating adding elements:
   - Add a node to an empty list.
   - Add nodes to the end of the list.
   - Add nodes to the middle of the list.

### Sample Code for Middle Insertion

Following the task list, a sample set of operations is presented to demonstrate how to add a node to the middle of the list:

- **Iteration Reset**: Prepares the list for traversal.
- **Navigation**: Moves to the next node.
- **Display Operations**: Shows the current states of the list before and after the insertion.
- **Node Insertion**: Inserts a specified node ("ENG211") after the current node.

### Continuation Tasks

8. **Further Operations**: Demonstrates various additional functionalities:
   - Describe the operation of a doubly-linked list.
   - Delete operations (first, middle, and last nodes).
   - Adding more nodes.
   - Iterating through the list (both forward and reverse).
9. **Final Operations**: Identify nodes based on specific conditions and display the final list.

### Note

The provided list of tasks acts as a framework. Users are encouraged to experiment by adding or removing nodes to further explore the workings of doubly-linked lists.

This educational framework serves to provide students or developers foundational insights into handling doubly-linked lists, making it suitable for beginner to intermediate learners in computer science domains.
Transcribed Image Text:This code snippet demonstrates a framework for implementing and manipulating a doubly-linked list in Java. Here's a detailed transcription and explanation of the code: ### Code Overview The class `DriverDoublyLinkedList_Framework` contains the `main` method, which outlines a series of tasks related to creating and manipulating a doubly-linked list. These tasks can serve as a guideline for understanding how various operations on a doubly-linked list function. ### Tasks 1. **Variable Definition**: Initialize the necessary variables for your application. 2. **Instantiation**: Create a new doubly-linked list. 3. **Display List State**: Show the current state of the list and format it for clarity. 4. **Build the List**: Add nodes to the list, demonstrating adding elements: - Add a node to an empty list. - Add nodes to the end of the list. - Add nodes to the middle of the list. ### Sample Code for Middle Insertion Following the task list, a sample set of operations is presented to demonstrate how to add a node to the middle of the list: - **Iteration Reset**: Prepares the list for traversal. - **Navigation**: Moves to the next node. - **Display Operations**: Shows the current states of the list before and after the insertion. - **Node Insertion**: Inserts a specified node ("ENG211") after the current node. ### Continuation Tasks 8. **Further Operations**: Demonstrates various additional functionalities: - Describe the operation of a doubly-linked list. - Delete operations (first, middle, and last nodes). - Adding more nodes. - Iterating through the list (both forward and reverse). 9. **Final Operations**: Identify nodes based on specific conditions and display the final list. ### Note The provided list of tasks acts as a framework. Users are encouraged to experiment by adding or removing nodes to further explore the workings of doubly-linked lists. This educational framework serves to provide students or developers foundational insights into handling doubly-linked lists, making it suitable for beginner to intermediate learners in computer science domains.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education