I need to create a hash table to store values for (possibly all) permutations of 123456789
, which is exactly 362 880 keys.
Given that I know how all the keys look up front, it seems I that there should be an optimal hashing function, and an optimal size of the table to store the values in.
Is this true? If so, how can I create the perfect hashing function? And also, how can I determine the optimal size for the hash table?
update: I'm looking to store all of the possible permutations, where each will be stored only once, which means the table should in the end contain exactly all 362 880 keys (since I have a hard limit on my algorithm for which I need to optimize my worst case scenario.)