Which collision resolution strategy generally performs better in terms of cache locality?
Both perform equally well
Cache locality is irrelevant to hash tables
Separate Chaining
Open Addressing
In a hash table using double hashing, the second hash function is used to:
Calculate the size of the hash table.
Generate a new key if a collision occurs.
Determine the initial index to store the key.
Determine the step size for probing in case of a collision.
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?
Quadratic Probing
Double Hashing
Linear Probing
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
Array
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.
What is the primary reason for using a prime number as the size of a hash table in many implementations?
To make the implementation of the hash table simpler.
To ensure an even distribution of keys across the hash table, reducing collisions.
To increase the speed of hash function computation.
To minimize the memory usage of the hash table.
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.
How can a hash flooding attack impact the performance of a web server using a hashmap to store session data?
It can lead to increased memory usage and faster response times.
It can improve the efficiency of the hashmap by distributing data more evenly.
It has no impact on performance, as hash flooding attacks only target data integrity.
It can cause a denial-of-service by forcing the server to handle a large number of collisions.
What is a common disadvantage of using a hashmap with a poorly chosen hash function?
Increased memory usage
Frequent hash collisions
Slow key generation
Inability to handle duplicate keys
Why is it generally recommended to avoid using mutable objects as keys in hash tables?
Using mutable keys increases the memory overhead of the hash table.
Mutable keys can lead to inconsistent state if their values are modified after being inserted into the hash table.
Hash tables cannot store mutable objects as keys; only immutable objects are allowed.
Mutable keys make the implementation of the hash table significantly more complex.