Abstract
As mentioned in the introduction, this book is primarily about implementing hash tables and not hash functions. So to simplify the exposition, assume that the data values stored in tables are identical to the hash keys. In Chapter 5, you will address which changes you have to make to store application data together with keys, but for most of the theory of hash tables you only need to consider hash keys; everywhere else, you will view additional data as black box data and just store their keys. While the code snippets below cover all that you need to implement the concepts in the chapter, you cannot easily compile them from the book, but you can download the complete code listings from https://github.com/mailund/JoyChapter2 .
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
It is technically possible to use the array in the table without initializing it, but it requires some trickery that incurs overhead.
- 2.
- 3.
You cannot make a perfectly fair such mapping if N if m does not divide N —x mod m cannot do this either. However, if N >> m, then you can get very close.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2019 Thomas Mailund
About this chapter
Cite this chapter
Mailund, T. (2019). Hash Keys, Indices, and Collisions. In: The Joys of Hashing. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4066-3_2
Download citation
DOI: https://doi.org/10.1007/978-1-4842-4066-3_2
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-4065-6
Online ISBN: 978-1-4842-4066-3
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)