Question: Check the bottom picture description #include #include #include #include #include #include using namespace std; // implementing the dynamic List ADT using Linked List class Node{

Check the bottom picture description
#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;
}
 Check the bottom picture description #include #include #include #include #include #include
Project 2: Implementation of the Merge List Function (for Merger of Unique Elements) for Singly Linked List and the Time Complexity Analysis Due by: September 18th, 11.59 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 will 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 1122 44->55 >78 89 56 --77--32. 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. max Value: 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 plot) as follows: (1) max Value 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 secondlntegerList) to the firstIntegerList only if the element is not already in the latter. Provide a pseudo code for the entire merge list function (including the logic for merger of unique elements) and analyze its time complexity as a function of the list size, n. (b - 45 pts) Include the complete C++ code comprising of the Node class, List class with all the added member functions and the main function. (c-11 pts) Tabulate the actual values of the run time (in milliseconds) for the combinations of max Value and listSize given. (d 12 pts) Present Excel bar charts (using the two ways prescribed) for the run time (plotted in logarithm of the milliseconds observed) (e 12 pts) From the bar charts, infer whether (on a relative basis) there is a significant increase in the run time with increase in listSize (for a given max Value) or there is a significant increase in the run time with increase in max Value (for a given listSize)

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!