Question: this is the code: #include #include #include #include #include #include using namespace std; // implementing the dynamic List ADT using Linked List class Node{ private:

 this is the code: #include #include #include #include #include #include using

namespace std; // implementing the dynamic List ADT using Linked List class

this is the code:

#include

#include

#include

#include

#include

#include

using namespace std;

// implementing the dynamic List ADT using Linked List

class Node{

private:

int data;

Node* nextNodePtr;

public:

Node(){}

void setData(int d){

data = d;

}

int getData(){

return data;

}

void setNextNodePtr(Node* nodePtr){

nextNodePtr = nodePtr;

}

Node* getNextNodePtr(){

return nextNodePtr;

}

};

class List{

private:

Node *headPtr;

public:

List(){

headPtr = new Node();

headPtr->setNextNodePtr(0);

}

Node* getHeadPtr(){

return headPtr;

}

bool isEmpty(){

if (headPtr->getNextNodePtr() == 0)

return true;

return false;

}

void insert(int data){

Node* currentNodePtr =

headPtr->getNextNodePtr();

Node* prevNodePtr = headPtr;

while (currentNodePtr != 0){

prevNodePtr = currentNodePtr;

currentNodePtr =

currentNodePtr->getNextNodePtr();

}

Node* newNodePtr = new Node();

newNodePtr->setData(data);

newNodePtr->setNextNodePtr(0);

prevNodePtr->setNextNodePtr(newNodePtr);

}

void insertAtIndex(int insertIndex, int data){

Node* currentNodePtr =

headPtr->getNextNodePtr();

Node* prevNodePtr = headPtr;

int index = 0;

while (currentNodePtr != 0){

if (index == insertIndex)

break;

prevNodePtr = currentNodePtr;

currentNodePtr =

currentNodePtr->getNextNodePtr();

index++;

}

Node* newNodePtr = new Node();

newNodePtr->setData(data);

newNodePtr->setNextNodePtr(currentNodePtr);

prevNodePtr->setNextNodePtr(newNodePtr);

}

int read(int readIndex){

Node* currentNodePtr =

headPtr->getNextNodePtr();

Node* prevNodePtr = headPtr;

int index = 0;

while (currentNodePtr != 0){

if (index == readIndex)

return

currentNodePtr->getData();

prevNodePtr = currentNodePtr;

currentNodePtr =

currentNodePtr->getNextNodePtr();

index++;

}

return -1; // an invalid value indicating

// index is out

of range

}

void modifyElement(int modifyIndex, int data){

Node* currentNodePtr =

headPtr->getNextNodePtr();

Node* prevNodePtr = headPtr;

int index = 0;

while (currentNodePtr != 0){

if (index == modifyIndex){

currentNodePtr->setData(data);

return;

}

prevNodePtr = currentNodePtr;

currentNodePtr =

currentNodePtr->getNextNodePtr();

index++;

}

}

void deleteElement(int deleteIndex){

Node* currentNodePtr =

headPtr->getNextNodePtr();

Node* prevNodePtr = headPtr;

Node* nextNodePtr = headPtr;

int index = 0;

while (currentNodePtr != 0){

if (index == deleteIndex){

nextNodePtr =

currentNodePtr->getNextNodePtr();

break;

}

prevNodePtr = currentNodePtr;

currentNodePtr =

currentNodePtr->getNextNodePtr();

index++;

}

prevNodePtr->setNextNodePtr(nextNodePtr);

}

void IterativePrint(){

Node* currentNodePtr =

headPtr->getNextNodePtr();

while (currentNodePtr != 0){

cout getData()

";

currentNodePtr =

currentNodePtr->getNextNodePtr();

}

cout

}

// add member function(s) here to accomplish the unique merger

// as explained in the project description

};

int main(){

int maxValue;

cout

cin >> maxValue;

int listSize;

cout

cin >> listSize;

srand(time(NULL));

using namespace std::chrono;

List firstIntegerList;

for (int i = 0; i

int value = 1 + rand() % maxValue;

firstIntegerList.insertAtIndex(i, value);

}

List secondIntegerList;

for (int i = 0; i

int value = 1 + rand() % maxValue;

secondIntegerList.insertAtIndex(i, value);

}

high_resolution_clock::time_point t1 = high_resolution_clock::now();

firstIntegerList.mergeList(secondIntegerList);

high_resolution_clock::time_point t2 = high_resolution_clock::now();

duration mergingTime_milli = t2 - t1;

double mergingTime = mergingTime_milli.count();

cout

return 0;

}

ds/CSC228-60-Sp2018-Project-2-LinkedList-UniqueMerger.pdf Singly Linked List and the Time Complexity Analysis Due: February 14, 12 PM In the code given to you for this project, you can notice in the main function that you will be creating two lists (called firstIntegerList and secondintegerList) of the same size (listSize) and whose values are in the range [1..max Value]. Add a member function mergeList to the Singly Linked List-based implementation of the List ADT. The member function takes as input a List object (representing the second integer list) as parameter and appends it to the List object (representing the first integer list) on which the function wil be called. You should append only those elements (from the second integer list) that are not already in the first integer list. Feel free to create additional member functions to facilitate this. For example: if the firstIntegerlist is 11 22 44 55--> 78--> 89 and the secondIntegerlist is 22 -> 56--> 89--> 77-.> 32 55, then the contents of the firstIntegerlist (after the merger) should be : 11224455-7889567732 The main function has the timers setup to merge the two lists and print the merging time in milliseconds. You should run the code for the following combinations of values for the two variables and tabulate the results. maxValue: 1000, 10000, 100000 listSize: 1000, 10000. 100000 Plot bar charts (in Excel) of the logarithm values of the run time (since the run time values will be of different ranges for the above combinations of values, we will take the natural logarithm, to the base e, in Excel and use these values to plotx) as follows: (1) maxValue in X-axis and the listSize in Y-axis (2) listSize in X-axis and the max Value in Y-axis Submission (in Canvas): Submit a singly report that has the following: (a - 20 pts) Explain the logic/algorithm that you incorporated to your code to accomplish the merger of only unique elements: i.e.. to merge an element (from the secondintegerList) to the firstIntegerList only if e-handout ( pof Q Lab2-Schematicsa pdf ^ Programming R--.pptm ^ 2lecture-handoutpdf

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!