Question: 13) This question uses the Nodexrs and LinkedListeT> classes below: publie class Node private T private NodeT data; nexti public Node (T data) public T

 13) This question uses the Nodexrs and LinkedListeT> classes below: publie
class Node private T private NodeT data; nexti public Node (T data)

13) This question uses the Nodexrs and LinkedListeT> classes below: publie class Node private T private NodeT data; nexti public Node (T data) public T getData() public public void setNext (NodesT> next) this.next next: this.data- datai return data: return next: Node private NodesT private NodeT> head, tail: Write a method for the LinkedListclass whose declaration is void duplicate(T x, TY) throws 11legalArgumentException 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 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. method Example: BEFORE: 1 ? 2 ? 3 ? 4? 5 Then duplicate (3,4) AFTER: 1 234345 Hint: Your code should first take care of the corner case where the length 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!