I came across a situation where i had to count the number of occurences of each word in a string. I decided hashing would be the best way to do it (Find the hash value for each word that is encountered and increment the count at the position indexed by the hash value - assuming i use an array). What hashing algorithm can i use to ensure that the hash value generated for every string is unique?
And this led to a bigger question.. How do the language libraries (Java for example) implement data structures like hashmap that generate unique hash values in case of strings?
I want to know the mathematical construct involved behind the implementation of such an algorithm.