In the context of hashmaps, what is a 'universal hash function' primarily designed to protect against?
Data corruption caused by accidental hash collisions between legitimate inputs.
Attempts to guess the keys used in the hashmap by analyzing the distribution of hashed values.
Denial-of-service attacks caused by hash flooding.
Collisions caused by malicious input specifically crafted to exploit a known hash function.
What is the primary advantage of using a universal hash function?
It ensures constant-time performance for all operations.
It eliminates the possibility of collisions entirely.
It provides better performance than any single, fixed hash function.
It makes the hash table resistant to attacks that exploit patterns in the hash function.
In cuckoo hashing, how many hash functions are typically used?
3
1
It depends on the size of the hash table.
2
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 eliminates the possibility of hash collisions.
It prevents unauthorized users from accessing the hashmap's keys.
Python dictionaries use open addressing for collision resolution. Which of the following techniques helps mitigate the performance degradation caused by clustering in open addressing?
Separate Chaining
Using a cryptographic hash function
Linear Probing with a prime step size
Robin Hood Hashing
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(log n)
O(1)
O(n log n)
O(n)
How can a hash flooding attack impact the performance of a web server using a hashmap to store session data?
It can cause a denial-of-service by forcing the server to handle a large number of collisions.
It can improve the efficiency of the hashmap by distributing data more evenly.
It can lead to increased memory usage and faster response times.
It has no impact on performance, as hash flooding attacks only target data integrity.
In the context of hash tables, what does a high load factor indicate?
A higher probability of collisions.
Faster insertion operations.
A more efficient hash function is being used.
Lower memory usage.
Which of the following statements accurately describes a key difference in the behavior of Python dictionaries and Java HashMaps?
Python dictionaries use separate chaining for collision resolution, while Java HashMaps employ open addressing.
Java HashMaps allow null keys and values, while Python dictionaries do not.
Python dictionaries maintain insertion order, while Java HashMaps do not guarantee any specific order.
Java HashMaps are synchronized and thread-safe, whereas Python dictionaries are not.
In Python, what is the purpose of the __hash__ method when used in conjunction with dictionaries?
__hash__
To determine the maximum number of elements that can be stored in the dictionary before resizing.
To provide a mechanism for iterating over the key-value pairs in the dictionary.
To specify how a custom object should be converted into a hash value for use as a key.
To define a custom sorting order for keys in the dictionary.