Load Factor of a Hash Table
A load factor compares stored entries with table slots or buckets according to the table's design.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Estimate occupancy
Six entries in eight slots give load factor \(6/8=0.75\). A chained table may also allow more entries than buckets. An open-addressed table needs its probing rule and available slots to store additional entries. Bucket collisions explain why the ratio alone cannot guarantee low lookup cost.
Check resizing effects
Growing to sixteen slots reduces that ratio to 0.375 if all six entries remain. Entries generally need placement according to the new indexing rule. See dynamic array growth for the general distinction between size and capacity.[1]
Relate a table-wide ratio to individual searches
Six entries in eight buckets give load factor \(\alpha=6/8=0.75\). Separate chaining can hold more entries than buckets, while ordinary open addressing requires vacant capacity for new insertions. Two equal load factors can hide very different distributions. See linear probing.
Example bucket counts with 8 buckets
Evenly spread: 1,1,1,1,1,1,0,0
Clustered: 6,0,0,0,0,0,0,0
Both have 6 entries; longest chain differs
Choose when to resize with the method in mind
A resize threshold is a policy that balances extra memory against search cost. For probing, recently removed entries may still affect lookup even if they no longer count as live keys. Test workload history as well as total population.