How does universal hashing enhance the robustness of hash tables?
By minimizing the impact of hash collisions on retrieval time
By ensuring a uniform distribution of keys across the hash table
By eliminating the possibility of hash collisions entirely
By dynamically adjusting the hash function to the input data
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 sorted linked list where each node contains a word and its frequency
Two arrays: one for storing words and one for storing their frequencies
A binary tree where words are stored in the nodes and their frequencies are stored in the leaves
A hashmap where words are keys and their frequencies are values
In a web server, which scenario is best suited for using a hashmap to optimize performance?
Managing the order of user connections to ensure fairness
Storing and retrieving user session data
Storing and retrieving static website content like images and CSS files
Maintaining a log of all incoming requests in chronological order
How does an increasing load factor generally impact the performance of a hashmap?
It has no significant impact on performance.
It depends on the specific hash function being used.
It degrades performance due to a higher probability of collisions.
It improves performance by reducing memory usage.
Which collision resolution strategy is generally preferred for hash tables with open addressing when the load factor is low?
Quadratic Probing
Separate Chaining
Double Hashing
Linear Probing
How does the choice of a hash function impact the performance of a hashmap?
The hash function has a negligible impact on performance compared to the data structure itself.
A well-chosen hash function minimizes collisions, leading to faster lookups and insertions.
A complex hash function guarantees a lower collision rate, improving performance.
A simple hash function is always preferred as it reduces computational overhead.
In the context of hash functions, what does the avalanche effect refer to?
Uneven distribution of keys within the hash table
Gradual degradation of hash performance over time
Increased likelihood of hash collisions with larger datasets
A small change in input causing a significant change in output
What is a primary disadvantage of using linear probing for collision resolution in a hash table?
Not suitable for open addressing
Complex implementation
Increased potential for primary clustering
Higher memory overhead compared to chaining
In a hash table using open addressing with quadratic probing, if the initial hash function maps a key to index 'i', and a collision occurs, what is the index probed in the second attempt (assuming table size 'm')?
(i + 2) % m
(i * 2) % m
(i + 1) % m
(i + 4) % m
In a system where memory usage is a major concern, what trade-off should be considered when using a hashmap?
Collision resolution strategies have no impact on memory consumption.
Using a complex hash function always reduces collisions and memory usage.
Hashmaps always use less memory than arrays for storing the same data.
A larger hash table size generally results in faster lookups but consumes more memory.