What does the load factor in a hash table represent?
Think about how full the hash table is compared to its capacity.
The load factor is the ratio of stored elements to buckets, indicating how full the hash table is. It helps decide when to resize the table.
What is the most likely effect of a high load factor on a hash table's performance?
Consider what happens when many elements share the same bucket.
A high load factor means more elements per bucket, causing more collisions and slower operations.
Why is rehashing performed in a hash table?
Think about what happens when the table becomes too full.
Rehashing increases the number of buckets and redistributes elements to keep operations efficient.
Given a hash table with 100 buckets and 75 stored elements, should rehashing be triggered if the load factor threshold is 0.7?
Calculate the load factor and compare it to the threshold.
Load factor = 75/100 = 0.75, which is greater than 0.7, so rehashing should occur.
Which rehashing strategy is generally more efficient in maintaining hash table performance as it grows?
Consider how the size increase affects load factor and performance.
Doubling buckets quickly reduces load factor and keeps operations efficient, while small increases cause frequent rehashing.