{
  "slug": "minimal-perfect-hash-function",
  "term": "Minimal perfect hash function",
  "aliases": [
    "MPHF",
    "minimal perfect hashing"
  ],
  "definition": "A minimal perfect hash function maps a fixed set of n distinct keys bijectively to n consecutive indices without identifying every key outside that set.",
  "note": "Minimality concerns the output range: n keys occupy exactly n indices. It does not mean that the representation uses the least possible memory. The collision-free guarantee applies to the construction set, not every possible query. [survey]\n\nMembership: A valid index is not proof that a key exists. An exact dictionary can keep the full key at each assigned index and compare it with the query before returning its value. A short fingerprint permits false matches and is a different contract. [bbhash-api]\n\nBBHash assigns noncolliding keys at successive bit-vector levels and uses rank to obtain dense indices. Colliding construction keys continue to later levels. Its lookup can return ULLONG_MAX for an absent key, but can also return another key's index; checking only that sentinel is insufficient. [bbhash-paper] [bbhash-api]\n\nStorage use: The function plus an indexed value array implements retrieval for a static key set. Values may change without changing the key set, but adding keys needs a construction or update strategy. Function-size figures exclude the separate values and membership evidence. [survey]",
  "related": [
    "retrieval-data-structure",
    "hash-collision",
    "bloom-filter"
  ],
  "citations": [
    {
      "id": "survey",
      "title": "Lehmann et al. Modern Minimal Perfect Hashing: A Survey. arXiv:2506.06536v3, sections 1-2.",
      "url": "https://arxiv.org/abs/2506.06536v3",
      "accessed": "2026-11-10"
    },
    {
      "id": "bbhash-paper",
      "title": "Limasset, Rizk, Chikhi and Peterlongo. Fast and Scalable Minimal Perfect Hashing for Massive Key Sets. SEA 2017, section 2.",
      "url": "https://doi.org/10.4230/LIPIcs.SEA.2017.25",
      "accessed": "2026-11-10"
    },
    {
      "id": "bbhash-api",
      "title": "BBHash README: querying keys outside the input set, commit be4220c8f8580299b212a0c6c6c867528a0f07ac.",
      "url": "https://github.com/rizkg/BBHash/blob/be4220c8f8580299b212a0c6c6c867528a0f07ac/README.md#querying-keys-that-are-not-in-the-input-set",
      "accessed": "2026-11-10"
    },
    {
      "id": "replay",
      "title": "Hesela: pinned BBHash membership replay, source, method and receipt.",
      "url": "https://hesela.dev/research/perfect-hash-membership/README.md",
      "accessed": "2026-11-10"
    }
  ],
  "status": "research",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-10",
  "provenance": [
    "The survey sections 1-2 and SEA 2017 method section support the scope distinction; historical benchmark rankings are not repeated.",
    "Pinned BBHash lookup code and an executable finite synthetic-key replay check membership behavior, not throughput or a population false-positive rate. [replay]"
  ]
}
