Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Write a Java method merge to create a new doubly linked list N that contains elements alternately from two given doubly linked lists L
4. Write a Java method merge to create a new doubly linked list N that contains elements alternately from two given doubly linked lists L and M. If you run out of elements in one of the lists, then append the remaining elements of the other list to N. Lists L and M should remain unchanged. The method should work for all lists, including empty lists. If any one of the two lists is empty, then the method should return a copy of the second list. For example, if list L contains 4 elements one, two, three, four, and list M contains 6 elements a, b, c, d, e", "1", then list N should contain the following elements: "one", "a", "two", "b", "three", "c" "four", "d", "e", "t". The method merge should have two parameters of type DList (references to lists L and M). It should return a reference of type DList) to the created list N. 5. The main method of DLinkTester class should test all your methods. Make sure to fully exercise the code of the methods (see p. 28 of the textbook). (Note: DList class has toString method that you can use to output list contents.)
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