Here is the result of the hash function:
Name |
Sum of Characters |
hash(name) |
George |
57 |
7 |
Amy |
39 |
9 |
Alan |
28 |
8 |
Sandy |
63 |
3 |
and the hash table, after all the stores is:
If you take the product of a series of numbers and any value in the series is 0 then the entire product will be zero. Thus, if a=0, then any string containing “a” will have the hash function return 0. This is undesirable since many strings will hash to the same index (0) in the hash table. On the other hand, if a=1, then strings with the letter “a” will hash to many different locations, depending on the other characters in the string. This is the desired situation and is better.