There two templates resqured for vector and list#include #include #include #include // used for remove #include // clock_t, clock, CLOCKS_PER_SEC#include using namespace std; template class...

1 answer below »
There two templates resqured for vector and list#include #include

#include #include // used for remove
#include // clock_t, clock, CLOCKS_PER_SEC#include

using namespace std;
template class HashTableList{ protected: list< list="">< dt=""> >* htable; // list of list hash table

public: HashTableList
(); // default constructor ~HashTableList(); // destructor

void insert(string str); // insert a string into the right spot in the hash table int h(char a); // hash function - returns the keyvoid displayTable(); // display the contents of htable void remove(string str); // removes a names from htable
};


int main(){string tempName; // to store the name using cin

HashTableList* h2 = new HashTableList(); // hash table object for vector

char option; // to store the option from redirected input

// START CLOCK while(cin >> option) { switch(option){case 'D':{// call display methodbreak;}case 'I':{cin >> tempName;cout // call insert methodbreak;}case 'R':{cin >> tempName;cout // call remove methodbreak;}} // switch case} // while

// END CLOCK

// DISPLAY TIME

delete h2; return 0;}
For vector#include #include

#include #include // used for remove
#include // clock_t, clock, CLOCKS_PER_SEC#include

using namespace std;
template class HashTableVector{ protected: vector< vector="">< dt=""> >* htable; // vector of vector hash table

public: HashTableVector

(); // default constructor ~HashTableVector(); // destructor

void insert(string str); // insert a string into the right spot in the hash table int h(char a); // hash function - returns the keyvoid displayTable(); // display the contents of htablevoid remove(string str); // removes a names from htable
};
int main(){string tempName; // to store the name using cin

HashTableVector* h1 = new HashTableVector(); // hash table object for vector

char option; // to store the option from redirected input

// START CLOCK while(cin >> option) { switch(option){case 'D':{// call display methodbreak;}case 'I':{cin >> tempName;cout // call insert methodbreak;}case 'R':{cin >> tempName;cout // call remove methodbreak;}} // switch case} // while

// STOP CLOCK

// DISPLAY TIME

delete h1; return 0;}







Answered 7 days AfterAug 07, 2021

Answer To: There two templates resqured for vector and list#include #include #include #include // used for...

Kamal answered on Aug 12 2021
148 Votes
#include
#include
#include
#include // used for remove
#include .h> // clock_t, clock, CLOCKS_PER_SEC
#include
using namespace std;
template
class HashTableVector
{
protected:
vector< vector < DT > > htable; // vector of vector hash table
public:
HashTableVector
(); // default constructor
~HashTableVector(); // destructor
void insert(string str); // insert a string into the right spot in the hash table
int h(char a); // hash function - returns the key
    void displayTable(); // display the contents of htable
    void remove(string str); // removes a names from htable
};
template
HashTableVector
::HashTableVector()
{
    // create single vector
    vector
dtable;
    // initialize the vector
    dtable.assign(100, "\0");
    // initialize the nested vector
    htable.assign(25, dtable);
}
template
HashTableVector
::~HashTableVector()
{
    //delete[] htable;
}
template
void HashTableVector
::insert(string str)
{
    // get key
    int index = h(str[0]);
    // iterators
    vector>::iterator...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here