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 maintain insertion order, while Java HashMaps do not guarantee any specific order.
Java HashMaps are synchronized and thread-safe, whereas Python dictionaries are not.
Python dictionaries use separate chaining for collision resolution, while Java HashMaps employ open addressing.
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
Fine-grained locking at the bucket level
Read-write locks separating readers and writers
Lock-free data structures using atomic operations
In a hash table using double hashing, the second hash function is used to:
Determine the initial index to store the key.
Calculate the size of the hash table.
Generate a new key if a collision occurs.
Determine the step size for probing in case of a collision.
In Python, what is the purpose of the __hash__ method when used in conjunction with dictionaries?
__hash__
To provide a mechanism for iterating over the key-value pairs in the dictionary.
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 specify how a custom object should be converted into a hash value for use as a key.
What is a common disadvantage of using a hashmap with a poorly chosen hash function?
Inability to handle duplicate keys
Slow key generation
Increased memory usage
Frequent hash 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?
Linked list
Array
Queue
Tree
You are implementing an LRU (Least Recently Used) cache with a fixed capacity. Which data structure combination would be most suitable for efficiently managing the cache?
Array + Queue
Binary Search Tree + Heap
Hashmap + Stack
Hashmap + Doubly Linked List
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 eliminates the possibility of hash collisions.
It makes it significantly harder for attackers to perform rainbow table attacks.
It prevents unauthorized users from accessing the hashmap's keys.
In cuckoo hashing, how many hash functions are typically used?
2
3
1
It depends on the size of the hash table.
What is the primary advantage of using a universal hash function?
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.
It ensures constant-time performance for all operations.