Question: Write a method that has two linked list head references as parameters. Assume that linked lists contain integer data, and on each list, every element

Write a method that has two linked list head references as parameters. Assume that linked lists contain integer data, and on each list, every element is less than the next element on the same list. The method should create a new linked list that contains all the elements on both lists, and the new linked list should also be ordered (so that every element is less than the next element in the list). The new linked list should not eliminate duplicate elements (i.e., if the same element appears in both input lists, then two copies are placed in the newly constructed linked list). The method should return a head reference for the newly constructed linked list.

Step by Step Solution

3.55 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

struct Node combinestruct Node head1struct Node head2 Node list1head... View full answer

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 Data Structures and Other Objects Using Java Questions!