Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions