Question: PLEASE CODE IN C++ AND INCLUDE SCREENSHOTS!! PLEASE MAKE IT COPYABLE! #include #include //srand, rand #include //clock_t, clock, CLOCKS_PER_SEC using namespace std; // implementing hash
PLEASE CODE IN C++ AND INCLUDE SCREENSHOTS!! PLEASE MAKE IT COPYABLE!

#include #include //srand, rand #include //clock_t, clock, CLOCKS_PER_SEC using namespace std; // implementing hash tables as an array of linked lists 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 } bool deleteElement(int deleteData){ Node* currentNodePtr = headPtr->getNextNodePtr(); Node* prevNodePtr = headPtr; Node* nextNodePtr = headPtr; while (currentNodePtr != 0){ if (currentNodePtr->getData() == deleteData){ nextNodePtr = currentNodePtr->getNextNodePtr(); prevNodePtr->setNextNodePtr(nextNodePtr); return true; } prevNodePtr = currentNodePtr; currentNodePtr = currentNodePtr->getNextNodePtr(); } return false; } int countList(){ Node* currentNodePtr = headPtr->getNextNodePtr(); int numElements = 0; while (currentNodePtr != 0){ numElements++; currentNodePtr = currentNodePtr->getNextNodePtr(); } return numElements; } void IterativePrint(){ Node* currentNodePtr = headPtr->getNextNodePtr(); while (currentNodePtr != 0){ cout getData() getNextNodePtr(); } cout getNextNodePtr(); while (currentNodePtr != 0){ if (currentNodePtr->getData() == searchData) return true; currentNodePtr = currentNodePtr->getNextNodePtr(); } return false; } }; class Hashtable{ private: List* listArray; int tableSize; public: Hashtable(int size){ tableSize = size; listArray = new List[size]; } int getTableSize(){ return tableSize; } void insert(int data){ int hashIndex = data % tableSize; listArray[hashIndex].insert(data); } void deleteElement(int data){ int hashIndex = data % tableSize; while (listArray[hashIndex].deleteElement(data)); } bool hasElement(int data){ int hashIndex = data % tableSize; return listArray[hashIndex].containsElement(data); } void printHashTable(){ for (int hashIndex = 0; hashIndex > numElements; int maxValue; cout > maxValue; int hashTableSize; cout > hashTableSize; srand(time(NULL)); int array[numElements]; cout The objective of this project is to design and implement a (n) algorithm (using hash tables) to print exactly once the duplicate elements (the elements that appear more than once) in an array of integers. Use the code given for the hash table class (implemented using singly linked list) and the startup code for the main function to generate an array of integers. Test your code with the following values array size: 20, maximum value for an integer: 10 and hash table size: 11 Implement the algorithm in the main function itself in the space provided. Note that your algorithm should print the duplicate elements only once. For example, the following is the output for an array of random integers generated and hashed with the above parameter values. Note that even though the (duplicate) integers 7, 6, 4, 2, 5 appear more than once, they are printed only once as part of the output for the elements that repeat. Enter the number of elements you want to store in the hash table 20 Enter the maximum value for an elenent 10 Enter the size of the hash table: 11 Elements generated: 5 6 4 2 378 6 47 9 4 2 6 6 5 2 6 Elements that repeat: 76 4 2 5 Space complexity: You are free to use more than one hash table of the size input by the user for this problem. Submission (through Canvas): (1) Complete code of the main function implementing the algorithm as well as the code for the Hashtable, Node and Singly Linked List classes (2) A report: explain the logic behind your algorithm (that it indeed finds duplicate elements and also prints them exactly once), provide a pseudo code of the algorithm and justify that the time complexity of the algorithm is (n). Assume the time complexity to search for the presence/absence of an element in a Hashtable is (1). (3) Explain the purpose of each hash table used to accomplish the (n) time complexity (4) A screenshot of the output (similar to the sample provided above) of running your code for the main function after implementing the algorithm