Takeaways
- Collisions will always happen in hash tables, but if make a "good" hash function, we can significantly decrease the number of collisions.
- Use the entire key, use prime number as array size, and make sure array is big enough are ways to avoid a collision
- Linear probing and Seperate Chaining are ways to deal with collisions when they happen
- Linear probing tries to place the element at a nearby, open bucket
- Seperate chaining uses a list to hold multiple elements at the same bucket
Code
feb18 is a basic Student database HashTable that uses seperate chaining to deal with collisions
feb20 is some leetcode problems