Question: //main.cpp #include #include #include using namespace std; int hashFunction(string s, int M) { // Your Code Here //hash function to sum up the ASCII characters

//main.cpp
#include
#include
#include
using namespace std;
int hashFunction(string s, int M) {
// Your Code Here
//hash function to sum up the ASCII characters of the letters of the string
}
int countCollisions (int M, vector
int collisions = 0;
// Your Code Here
return collisions;
}
int main() {
vector
"always","there","for","you","valspar","ri","sh","tg","uf","the", "frogurt", "is",
"also", "cursed","Whats", "your", "name", "Homer", "Simpson", "What", "is", "favorite",
"team", "The", "Isotopes", "I", "like", "too"};
for (int i=1; i
cout\t"
}
return 1;
}
The Problem Task 1 Complete the function simple Hash Function in main.cpp that accepts a string and the size of the hash table 'int M'. So, basically it takes the string, performs some computation on it and then returns an index in the range 0 to (M-1). A simple implementation is to sum the ASCII values of the letters in a string. If the hash table size M is small compared to the resulting summations, then this hash function should do a good job of distributing strings evenly among the hash table slots, because it gives equal weight to all characters in the string. This is an example of the folding approach to designing a hash function. Note that the order of the characters in the string has no effect on the result. Task 2: Now write the function int countCollisions (int M, vector
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
