The hash function will depend on the range of key values and the number of buckets. The key is to design a function that allows the buckets to be uniform.  - Use prime number if doing modulo hashing, it results in more even distribution Ideally, a perfect hash function will be a one-one mapping between the key and the bucket.  However, in most cases, a hash function is not perfect, thus there is a tradeoff between the number of buckets and the size of the buckets ### Collision Resolution - If there is more than one item in a bucket, then there is a collision.  A collision resolution algorithm should solve the following questions: - How to organize the values in the same bucket? - What if too many values are assigned to the same bucket? - How to search for a target value in a specific bucket? - If a bucket holds a constant and small number of keys, then we can use an array to store keys in the same bucket.  If it holds a variable or large number of keys, we might need to use a height-balanced binary search tree. ### Types of Hash Functions - [[Multiplicative Hashing]]