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.
What is the primary advantage of using a universal 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.
It provides better performance than any single, fixed hash function.
Which of the following is NOT a valid mitigation strategy against hash flooding attacks?
Switching to a different data structure like a tree-based map that offers consistent performance.
Employing a bloom filter to quickly identify and discard potentially malicious input.
Implementing a random salt value in the hash function to make collisions unpredictable.
Using a fixed-size hashmap to limit the maximum number of collisions.
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?
Tree
Linked list
Array
Queue
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(1)
O(n)
O(log n)
How can a hash flooding attack impact the performance of a web server using a hashmap to store session data?
It has no impact on performance, as hash flooding attacks only target data integrity.
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 can cause a denial-of-service by forcing the server to handle a large number of collisions.
You are designing a system to store and retrieve frequently accessed data with high performance. Which of the following hash table collision resolution strategies would generally offer the BEST performance under high load factors?
Separate Chaining
Linear Probing
Double Hashing
Quadratic Probing
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.
Java HashMaps are synchronized and thread-safe, whereas Python dictionaries are not.
Python dictionaries maintain insertion order, while Java HashMaps do not guarantee any specific order.
In a hashmap implementation using open addressing with linear probing, what is the worst-case time complexity for searching for a key if the hash table is nearly full?
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 define a custom sorting order for keys in the dictionary.
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.