Question: stion uses the Node data: nexti public Node(T data) publie T getData() public Node T> getNext() this.data datai return data; ( return next:) public void

 stion uses the Node data: nexti public Node(T data) publie T

stion uses the Node data: nexti public Node(T data) publie T getData() public Node T> getNext() this.data datai return data; ( return next:) public void setNext (Nodexr next) this.next-nexti public class LinkedList head; tail; Write a method for the LinkedList class whose declaration is void duplicate(T x, T y) throws IllegalArgumentException The method should find the first node whose data is deep-equal to x, and where the next node's data is deep-equal to y. If no such combination of nodes is found, the method should throw IllegaLArgumentException with an appropriate message. If the combination is found, the method should add 2 new nodes after the node whose data is y. The first added node should have its data = x, and the second added node should have its data = y. Example: BEFORE: 1 2 >3->4>5 Then duplicate(3,4) AFTER: 1?2?3?4?3?4?5 gth of the linked list is

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!