Question: / * * * * * * * * * * * * * * * * * * * * * * * *

/*********************************************************/
//macro guard
#ifndef hash_table_h
#define hash_table_h
/*********************************************************/
//System includes
#include
#include
#include
/*********************************************************/
//local includes
template
class HashTable{
//data memeber: bucket array (a list vector)
//Each list is a pair list
std::vector>> table;
public:
//constructor
HashTable(){
//TO DO
HashTable(int size =11);
//make a HashTable of size 11, as per the specified f key
}
//Hash Function
//Division Hashing with a prime number close to the data size
int hash_function(const int& key){
return key %11;
}
//insert into the table
void insert(const int& key, const T& value){
//TO DO
//Hint: use 'std::make_pair(key, value)' to create a pair
}
//erase the with key = "key"
//return true if "key" exists and the pair erased
//return false if "key" does not exist
bool erase(const int& key){
//TO DO
//Hint: use pair_obj.first to return the first value of a pair object
//pair_obj.secod to return the second value of a pair object
}
//find the value with key = "key"
//If "key" exists, return true and the value
//else return false and a defaul (meaningless) value
std::pair find(const int& key){
//TO DO
//Don't forget it should return a pair
}
//modify the value with key = "key"
//If "key" exists, modify it's value to "value", and return true
//else, return false
bool modify(const int& key, const T& value){
//TO DO
}
};
#endif

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 Programming Questions!