Question: C++ question: Using a standard dictionary, and a table size that approximates a load factor of 1, compare the number of collisions produced by the

C++ question:

Using a standard dictionary, and a table size that approximates a load factor of 1, compare the number of collisions produced by the hash function in Figure 5.4 and the hash function in Figure 5.55. (Please program in C++ with explanations)

/** Figure 5.4 * A hash routine for string objects. */ unsigned int hash( const string & key, int tableSize ) { unsigned int hashVal = 0;

for( char ch : key ) hashVal = 37 * hashVal + ch;

return hashVal % tableSize; }

/** Figure 5.55 * FNV-1a hash routine for string objects. */ unsigned int hash( const string & key, int tableSize ) { unsigned int hashVal = 2166136261;

for( char ch : key ) hashVal = ( hashVal ch )* 16777619;

return hashVal % tableSize; }

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