In the context of hashmaps, what is a 'universal hash function' primarily designed to protect against?
Denial-of-service attacks caused by hash flooding.
Collisions caused by malicious input specifically crafted to exploit a known hash function.
Attempts to guess the keys used in the hashmap by analyzing the distribution of hashed values.
Data corruption caused by accidental hash collisions between legitimate inputs.
Which of these data structures can provide a more secure and performant alternative to a hashmap when handling user authentication data, especially in scenarios prone to hash flooding attacks?
Array
Tree
Linked list
Queue
How does using a cryptographic hash function with a random salt improve the security of a hashmap storing user credentials?
It encrypts the data stored in the hashmap, making it unreadable without the decryption key.
It makes it significantly harder for attackers to perform rainbow table attacks.
It prevents unauthorized users from accessing the hashmap's keys.
It eliminates the possibility of hash collisions.
Which collision resolution strategy generally performs better in terms of cache locality?
Cache locality is irrelevant to hash tables
Open Addressing
Both perform equally well
Separate Chaining
What is the primary advantage of using a universal hash function?
It provides better performance than any single, fixed hash function.
It ensures constant-time performance for all operations.
It makes the hash table resistant to attacks that exploit patterns in the hash function.
It eliminates the possibility of collisions entirely.
Why is it generally recommended to avoid using mutable objects as keys in hash tables?
Hash tables cannot store mutable objects as keys; only immutable objects are allowed.
Mutable keys can lead to inconsistent state if their values are modified after being inserted into the hash table.
Using mutable keys increases the memory overhead of the hash table.
Mutable keys make the implementation of the hash table significantly more complex.
What is a common disadvantage of using a hashmap with a poorly chosen hash function?
Frequent hash collisions
Slow key generation
Inability to handle duplicate keys
Increased memory usage
In a hash table with open addressing using linear probing, suppose we perform a sequence of insertions where each key hashes to the same index. What is the time complexity of the nth insertion in the worst case?
O(n log n)
O(log n)
O(1)
O(n)
How can a hash flooding attack impact the performance of a web server using a hashmap to store session data?
It can improve the efficiency of the hashmap by distributing data more evenly.
It can cause a denial-of-service by forcing the server to handle a large number of collisions.
It has no impact on performance, as hash flooding attacks only target data integrity.
It can lead to increased memory usage and faster response times.
In the context of hash tables, what does a high load factor indicate?
A more efficient hash function is being used.
Lower memory usage.
Faster insertion operations.
A higher probability of collisions.