In a hash table using double hashing, the second hash function is used to:
Determine the initial index to store the key.
Generate a new key if a collision occurs.
Calculate the size of the hash table.
Determine the step size for probing in case of a collision.
What mechanism does Java's ConcurrentHashMap employ to allow for concurrent reads and updates while maintaining thread safety?
A single global lock for all operations
Read-write locks separating readers and writers
Lock-free data structures using atomic operations
Fine-grained locking at the bucket level
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.
What security risk arises from storing sensitive data like passwords directly in a hashmap, even when hashed?
Hashmaps are inherently less secure than other data structures for storing passwords.
Hash collisions could allow attackers to bypass authentication.
An attacker gaining access to the hashmap could retrieve the plaintext passwords.
Storing any data in a hashmap increases the risk of SQL injection attacks.
Which of the following statements accurately describes a key difference in the behavior of Python dictionaries and Java HashMaps?
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.
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.
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.
In cuckoo hashing, how many hash functions are typically used?
2
1
It depends on the size of the hash table.
3
In the context of amortized analysis of hash table operations, what does the term "amortized" refer to?
The best-case time complexity of an operation.
The time complexity of an operation when the hash table is full.
The worst-case time complexity of an operation.
The average time complexity of an operation over a sequence of operations.
What is the primary advantage of using a universal hash function?
It provides better performance than any single, fixed hash function.
It eliminates the possibility of collisions entirely.
It ensures constant-time performance for all operations.
It makes the hash table resistant to attacks that exploit patterns in the hash function.
Python dictionaries use open addressing for collision resolution. Which of the following techniques helps mitigate the performance degradation caused by clustering in open addressing?
Linear Probing with a prime step size
Separate Chaining
Robin Hood Hashing
Using a cryptographic hash function