Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions