I'm currently looking at perfect hash functions. One thing I miss from the texts I've read so far is, how they cope when attempting to look up with a key that is outside of the set from which the perfect hash was generated from.
Given a set of keys, a “perfect” hash function is one that gives a different hash for each key. As soon as you try to apply it to a key outside that set, it is quite likely not “perfect” anymore.
Let’s say you are writing a compiler, and you found a”perfect” hash function that maps each reserved identifier of your programming language to a different hash code. And I give you a word that is not one of the reserved words of the language. If you apply your “perfect” hash function then the hash code is either not the hash code of a reserved word (you need to check for that case), or it may be the hash code of a reserved word ( you need to check for that as well). The advantage is that at most one check is needed.