struct { char *string; } buckets[10]; case 1: buckets[0] = "A"; buckets[1] = "B"; Assuming ASCII: n = key - 'A'; case 2: buckets[0] = "B"; buckets[1] = "A"; Assuming ASCII: n = 1 - (key - 'A'); case 3: buckets[0] = "ABC"; buckets[1] = "DEF"; 'A' + 'B' + 'C' = max Would this work: (('A' + 'B' + 'C') * 3) / numBuckets; 'D' + 'E' + 'F' = max An algorithm sort of evolves from these patterns. We could possibly have even greater performance by only doing keys that are sizeof (int) and aligned to sizeof (int). ABC 65 + 66 + 67 = 198 198 * 3 is 594 594 / numBuckets What if we do patterns likes: K+E+Y = max and the max becomes the last element in a bucket like so: (K+E+Y * numElements) / numBuckets DEF 68 + 69 + 70 = 207 So we have the values 198 and 207. Somehow we must map those to exact keys ALWAYS. Let's say that 207 becomes slot 1, and 198 becomes slot 0 The delta of 207 - 198 is 9 If we did key - 198 we could have a direct mapping of buckets[0] = "ABC" buckets[9] = "DEF" However this has a problem, and that is that keys like this will generate the same hash: CBA, BAC, etc. What if we multiply a character value by 2, 3, 4, .. ? (65 * 2) + (66 * 3) + (67 * 4) That appears to always be unique. One issue with this is that we have expanded the potential array size considerably. The min value (the key with the lowest number) would become 0, and any greater keys would be at high addresses. Would it be enough to do a multiply by 1,2,3, ...? That would probably improve the size. There is a way to produce an algorithm or find the proper algorithm, and the answer lies in mph and the other perfect hash code. Our simplistic hash wastes too much memory, but I wonder how the others fare. I had the idea of using 2 bytes and encoding the pointer value over a series. This could potentially save some space, but I'm not seeing all of the idea yet. We could scale the value produced by the KEY to produce a linear array of keyed values that are closer together. Provided that no collisions occur it should work. One problem would be handling remainders. This should be thought about. ---- study mph This is apparently a Pearson hash algorithm: hash = 0; for (i=0; i