Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 METHODStep 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