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 increase the speed of hash function computation.
To minimize the memory usage of the hash table.
To ensure an even distribution of keys across the hash table, reducing collisions.
In the context of amortized analysis of hash table operations, what does the term "amortized" refer to?
The average time complexity of an operation over a sequence of operations.
The worst-case time complexity of an operation.
The time complexity of an operation when the hash table is full.
The best-case time complexity of an operation.
What is a common disadvantage of using a hashmap with a poorly chosen hash function?
Frequent hash collisions
Increased memory usage
Inability to handle duplicate keys
Slow key generation
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
Which of the following statements accurately describes a key difference in the behavior of Python dictionaries and Java HashMaps?
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.
Java HashMaps allow null keys and values, while Python dictionaries do not.
Python dictionaries use separate chaining for collision resolution, while Java HashMaps employ open addressing.
In the context of hashmaps, what is a 'universal hash function' primarily designed to protect against?
Collisions caused by malicious input specifically crafted to exploit a known hash function.
Data corruption caused by accidental hash collisions between legitimate inputs.
Denial-of-service attacks caused by hash flooding.
Attempts to guess the keys used in the hashmap by analyzing the distribution of hashed values.
What is the primary advantage of using a universal hash function?
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.
It ensures constant-time performance for all operations.
Why is it generally recommended to avoid using mutable objects as keys in hash tables?
Mutable keys make the implementation of the hash table significantly more complex.
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.
Hash tables cannot store mutable objects as keys; only immutable objects are allowed.
How does using a cryptographic hash function with a random salt improve the security of a hashmap storing user credentials?
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.
It encrypts the data stored in the hashmap, making it unreadable without the decryption key.
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
Queue
Linked list