# Explicit and Efficient Hash Families Suffice for Cuckoo Hashing with a Stash

## Abstract

It is shown that for cuckoo hashing with a stash as proposed by Kirsch et al. (Proc. 16th European Symposium on Algorithms (ESA), pp. 611–622, Springer, Berlin, 2008) families of very simple hash functions can be used, maintaining the favorable performance guarantees: with constant stash size *s* the probability of a rehash is *O*(1/*n* ^{ s+1}), the lookup time and the deletion time are *O*(*s*) in the worst case, and the amortized expected insertion time is *O*(*s*) as well. Instead of the full randomness needed for the analysis of Kirsch et al. and of Kutzelnigg (Discrete Math. Theor. Comput. Sci., 12(3):81–102, 2010) (resp. *Θ*(log*n*)-wise independence for standard cuckoo hashing) the new approach even works with 2-wise independent hash families as building blocks. Both construction and analysis build upon the work of Dietzfelbinger and Woelfel (Proc. 35th ACM Symp. on Theory of Computing (STOC), pp. 629–638, 2003). The analysis, which can also be applied to the fully random case, utilizes a graph counting argument and is much simpler than previous proofs. The results can be generalized to situations where the stash size is non-constant.

## Keywords

Data structures Hash table Randomized algorithms Hash functions Cuckoo hashing Random graphs## Notes

### Acknowledgements

We thank Pascal Klaue for implementing the algorithms and carrying out the experiments presented in Sect. 7. We thank the anonymous reviewers, whose suggestions helped a lot in improving the presentation of this work. We especially thank one reviewer who pointed out the extensions to non-constant stash size and *κ*-wise independent hash families.

## References

- 1.Arbitman, Y.: Efficient dictionary data structures based on cuckoo hashing. Master’s thesis, Weizmann Institute of Science (2010) Google Scholar
- 2.Carter, L., Wegman, M.N.: Universal classes of hash functions. J. Comput. Syst. Sci.
**18**(2), 143–154 (1979) CrossRefMATHMathSciNetGoogle Scholar - 3.Devroye, L., Morin, P.: Cuckoo hashing: Further analysis. Inf. Process. Lett.
**86**(4), 215–219 (2003) CrossRefMATHMathSciNetGoogle Scholar - 4.Diestel, R.: Graph Theory. Springer, Berlin (2005) MATHGoogle Scholar
- 5.Dietzfelbinger, M., Hagerup, T., Katajainen, J., Penttonen, M.: A reliable randomized algorithm for the closest-pair problem. J. Algorithms
**25**(1), 19–51 (1997) CrossRefMATHMathSciNetGoogle Scholar - 6.Dietzfelbinger, M., Rink, M.: Applications of a splitting trick. In: Proc. 36th International Colloquium on Automata, Languages and Programming (ICALP). LNCS, vol. 5555, pp. 354–365. Springer, Berlin (2009) CrossRefGoogle Scholar
- 7.Dietzfelbinger, M., Schellbach, U.: On risks of using cuckoo hashing with simple universal hash classes. In: Proc. 20th ACM-SIAM Symp. on Discrete Algorithms (SODA), pp. 795–804 (2009) CrossRefGoogle Scholar
- 8.Dietzfelbinger, M., Weidling, C.: Balanced allocation and dictionaries with tightly packed constant size bins. Theor. Comput. Sci.
**380**(1–2), 47–68 (2007) CrossRefMATHMathSciNetGoogle Scholar - 9.Dietzfelbinger, M., Woelfel, P.: Almost random graphs with simple hash functions. In: Proc. 35th ACM Symp. on Theory of Computing (STOC), New York, NY, USA, pp. 629–638 (2003) Google Scholar
- 10.Fotakis, D., Pagh, R., Sanders, P., Spirakis, P.G.: Space efficient hash tables with worst case constant access time. Theory Comput. Syst.
**38**(2), 229–248 (2005) CrossRefMATHMathSciNetGoogle Scholar - 11.Goodrich, M.T., Mitzenmacher, M.: Privacy-preserving access of outsourced data via oblivious ram simulation. In: Proc. 38th International Colloquium on Automata, Languages and Programming (ICALP), pp. 576–587 (2011) CrossRefGoogle Scholar
- 12.Kirsch, A., Mitzenmacher, M., Wieder, U.: More robust hashing: cuckoo hashing with a stash. In: Proc. 16th European Symposium on Algorithms (ESA). LNCS, vol. 5193, pp. 611–622. Springer, Berlin (2008) Google Scholar
- 13.Kirsch, A., Mitzenmacher, M., Wieder, U.: More robust hashing: cuckoo hashing with a stash. SIAM J. Comput.
**39**(4), 1543–1561 (2009) CrossRefMATHMathSciNetGoogle Scholar - 14.Klassen, T.Q., Woelfel, P.: Independence of tabulation-based hash classes. In: Proc. 10th Theoretical Informatics—Latin American Symposium (LATIN). LNCS, vol. 7256, pp. 506–517. Springer, Berlin (2012) Google Scholar
- 15.Kutzelnigg, R.: A further analysis of cuckoo hashing with a stash and random graphs of excess
*r*. Discrete Math. Theor. Comput. Sci.**12**(3), 81–102 (2010) MATHMathSciNetGoogle Scholar - 16.Mitzenmacher, M., Vadhan, S.P.: Why simple hash functions work: exploiting the entropy in a data stream. In: Proc. 19th ACM-SIAM Symp. on Discrete Algorithms (SODA), pp. 746–755 (2008) Google Scholar
- 17.Pagh, R., Rodler, F.F.: Cuckoo hashing. J. Algorithms
**51**(2), 122–144 (2004) CrossRefMATHMathSciNetGoogle Scholar - 18.Pǎtraşcu, M., Thorup, M.: The power of simple tabulation hashing. J. ACM
**59**(3), 14 (2012) MathSciNetGoogle Scholar - 19.Siegel, A.: On universal classes of extremely random constant-time hash functions. SIAM J. Comput.
**33**(3), 505–543 (2004) CrossRefMATHMathSciNetGoogle Scholar - 20.Thorup, M., Zhang, Y.: Tabulation based 4-universal hashing with applications to second moment estimation. In: Proc. 15th ACM-SIAM Symp. on Discrete Algorithms (SODA), pp. 615–624 (2004) Google Scholar
- 21.Thorup, M., Zhang, Y.: Tabulation-based 5-independent hashing with applications to linear probing and second moment estimation. SIAM J. Comput.
**41**(2), 293–331 (2012) CrossRefMATHMathSciNetGoogle Scholar - 22.Wegman, M.N., Carter, L.: New hash functions and their use in authentication and set equality. J. Comput. Syst. Sci.
**22**, 265–279 (1981) CrossRefMATHMathSciNetGoogle Scholar - 23.Woelfel, P.: Asymmetric balanced allocation with simple hash functions. In: Proc. 17th ACM-SIAM Symp. on Discrete Algorithms (SODA), pp. 424–433 (2006) Google Scholar