Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 key void 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 method break; } case 'I': { cin >> tempName; cout // call insert method break; } case 'R': { cin >> tempName; cout // call remove method break; } } // 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 key void 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
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 method break; } case 'I': { cin >> tempName; cout // call insert method break; } case 'R': { cin >> tempName; cout // call remove method break; } } // switch case } // while
// STOP CLOCK
// DISPLAY TIME
delete h1; return 0;}



Answered 7 days After Aug 07, 2021

Solution

Kamal answered on Aug 12 2021
150 Votes
#include #include #include #include
used for remove
#include
clock_t, clock, CLOCKS_PER_SEC
#include using namespace std;
template class HashTableVecto
{
protected:
vecto
vector < DT > > htable;
vector of vector hash table
public:
HashTableVecto
DT>();
default constructo
~HashTableVector();
destructo
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 HashTableVecto
DT>::HashTableVector()
{
    
create single vecto
    vecto
DT> dtable;
    
initialize the vecto
    dtable.assign(100, "\0");
    
initialize the nested vecto
    htable.assign(25, dtable);
}
template HashTableVecto
DT>::~HashTableVector()
{
    
delete[] htable;
}
template void HashTableVecto
DT>::insert(string str)
{
    
get key
    int index = h(str[0]);
    
iterators
    vecto
vecto
string
::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