How are deletions typically handled in a hashmap with open addressing to avoid creating 'holes' that disrupt search operations?
By simply removing the element, leaving the slot empty.
Deletions are not allowed in hashmaps with open addressing.
By shifting all subsequent elements one position back to fill the gap.
By marking the slot as "deleted" and implementing a mechanism to handle such markers during search and insertion.
How does the choice of a hash function impact the performance of a hashmap?
A complex hash function guarantees a lower collision rate, improving performance.
A well-chosen hash function minimizes collisions, leading to faster lookups and insertions.
The hash function has a negligible impact on performance compared to the data structure itself.
A simple hash function is always preferred as it reduces computational overhead.
What is the primary advantage of using a hashmap over a simple array for storing and retrieving data?
Hashmaps use less memory than arrays.
Hashmaps provide faster access to data based on a key, while arrays require linear search in some cases.
Hashmaps can store duplicate keys, while arrays cannot.
Hashmaps maintain data in sorted order, unlike arrays.
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
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
A hashmap where words are keys and their frequencies are values
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
How does quadratic probing aim to mitigate the clustering problem in open addressing?
By probing with quadratically increasing intervals
By probing linearly with a fixed step size
By using a second hash function to determine the probe sequence
By probing with exponentially increasing intervals
In the context of hash functions, what does the avalanche effect refer to?
Gradual degradation of hash performance over time
Uneven distribution of keys within the hash table
Increased likelihood of hash collisions with larger datasets
A small change in input causing a significant change in output
In a web server, which scenario is best suited for using a hashmap to optimize performance?
Storing and retrieving user session data
Maintaining a log of all incoming requests in chronological order
Storing and retrieving static website content like images and CSS files
Managing the order of user connections to ensure fairness
In the worst-case scenario, what is the time complexity of searching for a key in a hashmap?
O(n log n)
O(1)
O(log n)
O(n)
What is the purpose of dynamic resizing (rehashing) in a hashmap?
To increase the size of the hash function's output range.
To improve the efficiency of key deletion operations.
To maintain a low load factor and prevent performance degradation.
To reduce the number of keys stored in the hashmap.