In a system where memory usage is a major concern, what trade-off should be considered when using a hashmap?
Using a complex hash function always reduces collisions and memory usage.
Collision resolution strategies have no impact on memory consumption.
A larger hash table size generally results in faster lookups but consumes more memory.
Hashmaps always use less memory than arrays for storing the same data.
What is a significant disadvantage of using a fixed-size hash table in conjunction with a hash function prone to collisions?
Inability to store data that exceeds the pre-defined table size
Complexity in implementing the hash function itself
Increased memory usage due to the fixed size allocation
Degraded performance due to chaining or open addressing for collision resolution
In the worst-case scenario, what is the time complexity of searching for a key in a hashmap?
O(n log n)
O(log n)
O(1)
O(n)
You need to count the frequency of each word in a large text document. Which combination of data structures would be most efficient for this task?
A hashmap where words are keys and their frequencies are values
A sorted linked list where each node contains a word and its frequency
A binary tree where words are stored in the nodes and their frequencies are stored in the leaves
Two arrays: one for storing words and one for storing their frequencies
What is a potential drawback of using double hashing for collision resolution compared to linear or quadratic probing?
Not suitable for use with open addressing
Higher risk of primary clustering
Requires dynamic memory allocation for linked lists
Increased computational cost due to the second hash function
How does universal hashing enhance the robustness of hash tables?
By dynamically adjusting the hash function to the input data
By eliminating the possibility of hash collisions entirely
By ensuring a uniform distribution of keys across the hash table
By minimizing the impact of hash collisions on retrieval time
Which collision resolution strategy is generally preferred for hash tables with open addressing when the load factor is low?
Linear Probing
Double Hashing
Quadratic Probing
Separate Chaining
How does an increasing load factor generally impact the performance of a hashmap?
It degrades performance due to a higher probability of collisions.
It improves performance by reducing memory usage.
It depends on the specific hash function being used.
It has no significant impact on performance.
In the context of hashmaps, what does 'probing' refer to?
Determining the load factor of the hashmap.
Finding an alternative slot for a key when a collision occurs.
Resizing the underlying array to accommodate more keys.
Searching for a specific key in the hashmap.
When does rehashing typically occur in a hashmap?
When the load factor exceeds a predetermined threshold.
Every time a new key is inserted.
When the hashmap is cleared using the clear() method.
When the hash function is modified.