Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// It is C++ for your information class Node { public: Node* next; int data; }; class LinkedList { public: LinkedList(); ~LinkedList(); void add(int data);

image text in transcribed

image text in transcribed

// It is C++ for your information

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

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago