Question: Java 1. Linked Lists (15 pts) Implement a (NON-RECURSIVE) method to find the common elements in two sorted linked lists, and return the common elements

Java Java 1. Linked Lists (15 pts) Implement a (NON-RECURSIVE) method to

1. Linked Lists (15 pts) Implement a (NON-RECURSIVE) method to find the common elements in two sorted linked lists, and return the common elements in sorted order in a NEW linked list. The original linked lists should not be modified. The new linked list should have a complete new set of Node objects (not shared with the original lists). Example: L1: 3->9->12->15-21 L2 : 2--3->6->12>19 Result: 3->12 You may assume that neither of the original lists has any duplicate items. public class Node ( public int data; public Node next; public Node (int data, Node next) this.data = data; this.next = next ; // Creates a new linked list consisting of the items common to the input lists // returns the front of this new linked list, null if there are no common items public static Node commonElements (Node frontLl, Node frontL2) // COMPLETE THIS METHOD

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!