Discuss a hashing function object for strings


Discuss the below:

Q: Consider the given hashing function object for strings. What can you say about strings "aefghk" and "gaefkh"? Is this a good hashing function? Why?

class hFstr
{
public:
unsigned int operator () (const string& s) const
{
int i;
unsigned int hashval = 0;

for ( i = 0; i < s.length(); i++)
hashval += s[i];

return hashval;
}
};

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Discuss a hashing function object for strings
Reference No:- TGS01937163

Now Priced at $25 (50% Discount)

Recommended (91%)

Rated (4.3/5)