Question
In java Write a method public void printReverse() that prints the elements of a doubly linked list in reverse. Write a method public void delete5FromTheEnd()
In java
Write a method public void printReverse() that prints the elements of a doubly linked list in reverse.
Write a method public void delete5FromTheEnd() which deletes the 5th element from end of the list. Note that if you reach the end then you have to reverse the direction of counting.
In the main() method of the test class, create a randomly generated Doubly-Linked list of 10 Integers. Next, call the delete5FromTheEnd() method and print the lists iteratively until the list becomes empty. Make sure to print the list after each deletion.
For example, your list initially could be:
[ 3 1 2 5 8 7 ].
After deleting 5th element from the end:
[ 3 1 2 5 8 7 ] => [ 3 2 5 8 7 ].
After deleting 5th element again;
[ 3 2 5 8 7] => [ 2 5 8 7].
After deleting 5th element again (counting in the reverse direction, then moving forward),
[ 2 5 8 7] => [ 2 8 7 ]
[2 8 7] => [2 8]
//**************************** DLL.java ******************************* // generic doubly linked list class
public class DLL
//**************************** DLLNode.java ******************************* // node of generic doubly linked list class
public class DLLNode
************************DLLTest.java*********************************
public class DLLTest { public static void main(String[] args) { DLL
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started