Sorting versus hashing
- by Paul Siegel
My problem is as follows. I have an array of n strings with m < n of them distinct. I want to create a one-to-one function which assigns each of the m distinct strings to the numbers 0 ... m-1. For example, if my strings are:
Bob, Amy, Bob, Charlie, Amy
then the function:
Bob -> 0, Amy -> 1, Charlie -> 2
would meet my needs. I…