in computer science, a perfect hash function h for a set s is a hash function that maps distinct elements in s to a set of m integers, with no collisions. in mathematical terms, it is an injective function.