Question: It is C++ class Node { public: Node* next; int data; }; class LinkedList { public: LinkedList(); ~LinkedList(); void add(int data); void InsertNth(int index, int

It is C++

It is C++ class Node { public: Node* next; int data; };

class LinkedList { public: LinkedList(); ~LinkedList(); void add(int data); void InsertNth(int index,

class Node { public: Node* next; int data; };

class LinkedList { public: LinkedList(); ~LinkedList(); void add(int data); void InsertNth(int index, int data); void RemoveDuplicates(); Node* head;

};

LinkedList::LinkedList() { this->head = nullptr; }

LinkedList::~LinkedList() { //TODO WITH LAB INSTRUCTOR }

void LinkedList::add(int data) { Node* node = new Node(); node->data = data; node->next = this->head; this->head = node; }

void LinkedList::InsertNth(int index, int data) { //TODO //Good luck :) }

void LinkedList::RemoveDuplicates() { //TODO //Good luck :) }

Remove Duplicates of Sorted Linked List(Definitely Not Easy) A THE LINKED LIST IS SORTED Your code will only be tested on linked lists where the list is sorted in ascending order. These would be examples 1. 8-9 -> 10->11 2. 8- 8-9-9 3. 8- 8-10-> 42 4. empty Your job is to write a RemoveDuplicates() function which deletes any duplicate nodes from the list. Ideally, the list should only traversed once So if you were given the lists above, your resulting linked list should be 1. 8-9->10->11 2. 8->9 3. 8- 10- 42 4. empty Guidelines . Again, assume that the list is sorted like the examples above Make sure you consider this case 1- 1-1->1 . Do not mess with the function declaration Only code within the RemoveDuplicates function To test your code run make RemoveDuplicatesTest Checkoff In order to be checked off run make all. This will run all the tests at once! Once they all pass go see a CP or TA :D

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!