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
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.
An attacker gaining access to the hashmap could retrieve the plaintext passwords.
Hashmaps are inherently less secure than other data structures for storing passwords.
Storing any data in a hashmap increases the risk of SQL injection attacks.
In the context of hash tables, what does a high load factor indicate?
Faster insertion operations.
A higher probability of collisions.
A more efficient hash function is being used.
Lower memory usage.
What is the primary reason for using a prime number as the size of a hash table in many implementations?
To increase the speed of hash function computation.
To minimize the memory usage of the hash table.
To make the implementation of the hash table simpler.
To ensure an even distribution of keys across the hash table, reducing collisions.
In Python, what is the purpose of the __hash__ method when used in conjunction with dictionaries?
__hash__
To specify how a custom object should be converted into a hash value for use as a key.
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.
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?
O(log n)
O(n)
O(n log n)
O(1)
In a hash table using double hashing, the second hash function is used to:
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.
Determine the initial index to store the key.
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?
Hashmap + Stack
Array + Queue
Hashmap + Doubly Linked List
Binary Search Tree + Heap
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.
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
Robin Hood Hashing
Using a cryptographic hash function
Linear Probing with a prime step size