Question: ( b ) Write a method called dedup ( ) in the class MyLinkedList, that removes duplicated values and leaves the list with only unique

(b) Write a method called dedup() in the class MyLinkedList, that removes duplicated values
and leaves the list with only unique values using the previous method contains (you are not
requested to preserve the original order of the list nodes).[4 marks]
Hint: To get the list deduplicated, we save the old head into another MyNode reference variable
(say head2), set head to null. We then insert every element from the original list into head only
when the list does not contain this element.
Linked list: 810828412106
Deduplicated Linked list: 6142108
ANSWER:
public void dedup()(
 (b) Write a method called dedup() in the class MyLinkedList, that

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!