Question: 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
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 inputs) lt takes the size of the hash table as input and a vector of strings. It goes over all the input strings, performs the above 'simpleHashFunction' over it and counts the total number of collisions at each index in the hash table (index ranging from 0 to M-1). In the main function, there is a code to test how the number of collisions change on chaging the size of the hash table. We vary the size from 1 to 11 Example output: Compile and Test A complete Makefile and a main. Cpp file containing one simple test has been provided for you. To compile and run, run:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
