previous
|
start
|
next
Computing Hash Codes
A hash function computes an integer hash code from an object
Choose a hash function so that different objects are likely to have different hash codes.
Bad choice for hash function for a string
Adding the unicode values of the characters in the string
int h = 0; for (int i = 0; i < s.length(); i++) h = h + s.charAt(i);
Because permutations ("eat" and "tea") would have the same hash code
previous
|
start
|
next