In a web server implemented using a hashmap to store cached web pages, which collision resolution strategy is generally preferred for its performance in handling a high volume of concurrent requests?
Double Hashing
Separate Chaining with balanced binary search trees
Open Addressing with linear probing
Separate Chaining with linked lists
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
Using a cryptographic hash function
Separate Chaining
Robin Hood Hashing
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 provides better performance than any single, fixed hash function.
It ensures constant-time performance for all operations.
It eliminates the possibility of collisions entirely.
What security risk arises from storing sensitive data like passwords directly in a hashmap, even when hashed?
Hash collisions could allow attackers to bypass authentication.
Storing any data in a hashmap increases the risk of SQL injection attacks.
Hashmaps are inherently less secure than other data structures for storing passwords.
An attacker gaining access to the hashmap could retrieve the plaintext passwords.
In the context of hash tables, what does a high load factor indicate?
Lower memory usage.
Faster insertion operations.
A more efficient hash function is being used.
A higher probability of collisions.
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?
O(log n)
O(1)
O(n log n)
O(n)
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
Hashmap + Stack
Binary Search Tree + Heap
Hashmap + Doubly Linked List
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?
In a hash table using double hashing, the second hash function is used to:
Calculate the size of the hash table.
Determine the step size for probing in case of a collision.
Determine the initial index to store the key.
Generate a new key if a collision occurs.
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 specify how a custom object should be converted into a hash value for use as a key.
To provide a mechanism for iterating over the key-value pairs in the dictionary.