Hash, Displace, and Compress

  • Djamal Belazzougui
  • Fabiano C. Botelho
  • Martin Dietzfelbinger
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5757)


A hash function h, i.e., a function from the set U of all keys to the range range [m] = {0,...,m − 1} is called a perfect hash function (PHF) for a subset S ⊆ U of size n ≤ m if h is 1-1 on S. The important performance parameters of a PHF are representation size, evaluation time and construction time. In this paper, we present an algorithm that permits to obtain PHFs with expected representation size very close to optimal while retaining O(n) expected construction time and O(1) evaluation time in the worst case. For example in the case m = 1.23n we obtain a PHF that uses space 1.4 bits per key, and for m = 1.01n we obtain space 1.98 bits per key, which was not achievable with previously known methods. Our algorithm is inspired by several known algorithms; the main new feature is that we combine a modification of Pagh’s “hash-and-displace” approach with data compression on a sequence of hash function indices. Our algorithm can also be used for k-perfect hashing, where at most k keys may be mapped to the same value.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Belazzougui, D., Botelho, F.C., Dietzfelbinger, M.: Hash, displace, and compress. Computer Research Repository (2009)Google Scholar
  2. 2.
    Botelho, F.C., Pagh, R., Ziviani, N.: Simple and space-efficient minimal perfect hash functions. In: Dehne, F., Sack, J.-R., Zeh, N. (eds.) WADS 2007. LNCS, vol. 4619, pp. 139–150. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  3. 3.
    Chazelle, B., Kilian, J., Rubinfeld, R., Tal, A.: The bloomier filter: An efficient data structure for static support lookup tables. In: Proc. of the 15th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 30–39. SIAM, Philadelphia (2004)Google Scholar
  4. 4.
    Dietzel, L.: Speicherplatzeffiziente perfekte Hashfunktionen. Master’s thesis, Technische Universität Ilmenau (Novmber 2005) (in German)Google Scholar
  5. 5.
    Dietzfelbinger, M.: Design strategies for minimal perfect hash functions. In: Hromkovič, J., Královič, R., Nunkesser, M., Widmayer, P. (eds.) SAGA 2007. LNCS, vol. 4665, pp. 2–17. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  6. 6.
    Dietzfelbinger, M., Rink, M.: Applications of a splitting trick. In: Proc. of 36th International Colloquium on Automata, Languages and Programming. Springer, Heidelberg (to appear, 2009)Google Scholar
  7. 7.
    Dietzfelbinger, M., Weidling, C.: Balanced allocation and dictionaries with tightly packed constant size bins. Theoretical Computer Science 380(1-2), 47–68 (2007)MathSciNetCrossRefMATHGoogle Scholar
  8. 8.
    Erlingsson, U., Manasse, M., McSherry, F.: A cool and practical alternative to traditional hash tables. In: Proc. of the 7th Workshop on Distributed Data and Structures, pp. 1–6 (2006)Google Scholar
  9. 9.
    Ferragina, P., Venturini, R.: A simple storage scheme for strings achieving entropy bounds. Theoretical Computer Science 372(1), 115–121 (2007)MathSciNetCrossRefMATHGoogle Scholar
  10. 10.
    Fredman, M.L., Komlós, J.: On the size of separating systems and families of perfect hashing functions. SIAM Journal on Algebraic and Discrete Methods 5, 61–68 (1984)MathSciNetCrossRefMATHGoogle Scholar
  11. 11.
    Fredriksson, K., Nikitin, F.: Simple compression code supporting random access and fast string matching. In: Demetrescu, C. (ed.) WEA 2007. LNCS, vol. 4525, pp. 203–216. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  12. 12.
    Hagerup, T., Tholey, T.: Efficient minimal perfect hashing in nearly minimal space. In: Ferreira, A., Reichel, H. (eds.) STACS 2001. LNCS, vol. 2010, pp. 317–326. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  13. 13.
    Litwin, W.: Linear hashing: a new tool for file and table addressing. In: Proc. of the 6th International Conference on Very Large Data Bases, pp. 212–223. VLDB Endowment (1980)Google Scholar
  14. 14.
    Mehlhorn, K.: Data Structures and Algorithms 1: Sorting and Searching. Springer, Heidelberg (1984)CrossRefMATHGoogle Scholar
  15. 15.
    Mitzenmacher, M., Upfal, E.: Probability and Computing. Cambridge University Press, Cambridge (2005)CrossRefMATHGoogle Scholar
  16. 16.
    Pagh, R.: Hash and displace: Efficient evaluation of minimal perfect hash functions. In: Dehne, F., Gupta, A., Sack, J.-R., Tamassia, R. (eds.) WADS 1999. LNCS, vol. 1663, pp. 49–54. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  17. 17.
    Radhakrishnan, J.: Improved bounds for covering complete uniform hypergraphs. Information Processing Letters 41, 203–207 (1992)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    Sanders, P.: Personal communication (2004)Google Scholar
  19. 19.
    Schmidt, J.P., Siegel, A.: The spatial complexity of oblivious k-probe hash functions. SIAM Journal on Computing 19(5), 775–786 (1990)MathSciNetCrossRefMATHGoogle Scholar
  20. 20.
    Tarjan, R.E., Yao, A.C.C.: Storing a sparse table. Communications of the ACM 22(11), 606–611 (1979)MathSciNetCrossRefMATHGoogle Scholar
  21. 21.
    Vigna, S.: Broadword implementation of rank/select queries. In: Proc. of the 7th International Workshop on Efficient and Experimental Algorithms, pp. 154–168. ACM Press, New York (2008)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Djamal Belazzougui
    • 1
  • Fabiano C. Botelho
    • 2
  • Martin Dietzfelbinger
    • 3
  1. 1.Ecole Nationale Supérieure d’InformatiqueAlgiersAlgeria
  2. 2.Department of Computer EngineeringFederal Center for Technological Education of Minas GeraisBelo HorizonteBrazil
  3. 3.Faculty of Computer Science and AutomationTechnische Universität IlmenauIlmenauGermany

Personalised recommendations