How does universal hashing enhance the robustness of hash tables?
By minimizing the impact of hash collisions on retrieval time
By dynamically adjusting the hash function to the input data
By eliminating the possibility of hash collisions entirely
By ensuring a uniform distribution of keys across the hash table
In the worst-case scenario, what is the time complexity of searching for a key in a hashmap?
O(n)
O(1)
O(log n)
O(n log n)
Which of the following scenarios could potentially lead to collisions in a hashmap?
Using a hash function that distributes keys evenly across the hash table
Storing keys with a wide range of values
Having a hash table size much larger than the number of keys being stored
Hashing two different keys to the same index in the hash table
What advantage does separate chaining have over open addressing techniques in hash table collision resolution?
Lower memory overhead
Simpler implementation
Handles load factors greater than 1 gracefully
Faster search times at high load factors
When does rehashing typically occur in a hashmap?
Every time a new key is inserted.
When the load factor exceeds a predetermined threshold.
When the hashmap is cleared using the clear() method.
When the hash function is modified.
What is a potential drawback of using double hashing for collision resolution compared to linear or quadratic probing?
Higher risk of primary clustering
Increased computational cost due to the second hash function
Not suitable for use with open addressing
Requires dynamic memory allocation for linked lists
Which collision resolution strategy is generally preferred for hash tables with open addressing when the load factor is low?
Double Hashing
Linear Probing
Separate Chaining
Quadratic Probing
In the context of hash functions, what does the avalanche effect refer to?
Increased likelihood of hash collisions with larger datasets
Gradual degradation of hash performance over time
Uneven distribution of keys within the hash table
A small change in input causing a significant change in output
How does an increasing load factor generally impact the performance of a hashmap?
It depends on the specific hash function being used.
It improves performance by reducing memory usage.
It has no significant impact on performance.
It degrades performance due to a higher probability of collisions.
In a web server, which scenario is best suited for using a hashmap to optimize performance?
Storing and retrieving user session data
Storing and retrieving static website content like images and CSS files
Managing the order of user connections to ensure fairness
Maintaining a log of all incoming requests in chronological order