Loading...
What happens when two keys hit the same slot? Master the strategies to resolve conflicts efficiently.
Section 0 of 0
What happens when two keys hit the same slot? Master the strategies to resolve conflicts efficiently.
Since your Hash Table has a fixed size (buckets) but the number of possible keys is infinite, at some point, two keys will map to the same slot. This is a collision. How you handle them determines the performance of your system.
Each bucket points to a linked list. Collisions are simply appended to the list.
When using Open Addressing (Linear/Quadratic), performance plummets as the table fills up.
The rule of thumb: Once your table is 70% full ($\alpha \approx 0.7$), you MUST Resize (Rehash) the table into a larger array.