Question: Linked Lists - Deque Implement a nested class DoubleNode for building doubly-linked lists, where each node contains a reference to the item preceding it and

Linked Lists - Deque Implement a nested class DoubleNode for building doubly-linked lists, where each node contains a reference to the item preceding it and the item following it in the list (null if there is no such item). Then implement methods for the following tasks: Print the contents of the list Insert at the beginning Insert at the end Remove from the beginning Remove from the end Insert before a give node (Insert before the first occurrence of the node, if the node exists; else insert at the end) Insert after a given node (Insert after the first occurrence of the node, if the node exists; else insert at the end) Remove a given node (Remove the first occurrence of the node, remove nothing if node not found) Move to front (move the first occurrence of the node to the front) Move to end (moved and first occurrence of the node to the end) Write a tester program and test your implementation. You must test each of these cases and print the list after each test and verify the correctness of the code.

Examples: Suppose the link list contains the following elements: C-> O -> M -> P -> U -> T -> E 1. Print the contents of the list: C-> O -> M -> P -> U -> T -> E 2. Insert M at the beginning of the list: M -> C-> O -> M -> P -> U -> T -> E 3. Insert R at the end: M -> C-> O -> M -> P -> U -> T -> E -> R 4. Remove from the beginning: C-> O -> M -> P -> U -> T -> E -> R

5. Remove from the end: C-> O -> M -> P -> U -> T -> E 6. Insert M before P: C-> O -> M -> M -> P -> U -> T -> E 7. Insert H before M: C-> O -> H -> M -> M -> P -> U -> T -> E -> B 8. Insert B before A: C-> O -> M -> M -> P -> U -> T -> E -> B 9. Insert C after P: C-> O -> M -> M -> P-> C -> U -> T -> E -> B 10. Insert L after M: C-> O -> M -> L -> M -> P -> C-> -> U -> T -> E -> B 11. Remove M C-> O -> L -> M -> P -> C-> -> U -> T -> E -> B 12. Remove G C-> O -> L -> M -> P -> C-> -> U -> T -> E -> B 13. Move P to the front of the list: P -> C-> O -> L -> M -> C-> -> U -> T -> E -> B 14. Move L to the end of the list: P -> C-> O -> M -> C-> -> U -> T -> E -> B -> L

in java please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!