How are deletions typically handled in a hashmap with open addressing to avoid creating 'holes' that disrupt search operations?
By shifting all subsequent elements one position back to fill the gap.
Deletions are not allowed in hashmaps with open addressing.
By simply removing the element, leaving the slot empty.
By marking the slot as "deleted" and implementing a mechanism to handle such markers during search and insertion.
Which of the following scenarios could potentially lead to collisions in a hashmap?
Hashing two different keys to the same index in the hash table
Having a hash table size much larger than the number of keys being stored
Storing keys with a wide range of values
Using a hash function that distributes keys evenly across the hash table
In the context of hash functions, what does the avalanche effect refer to?
Increased likelihood of hash collisions with larger datasets
Gradual degradation of hash performance over time
A small change in input causing a significant change in output
Uneven distribution of keys within the hash table
What is a primary disadvantage of using linear probing for collision resolution in a hash table?
Not suitable for open addressing
Increased potential for primary clustering
Complex implementation
Higher memory overhead compared to chaining
What is the significance of the output size of a cryptographic hash function?
Affects the uniqueness of the hash for different inputs
Impacts the resistance against brute-force attacks
Influences the memory required to store the hash function
Determines the speed of hash computation
Which collision resolution technique involves using a second, independent hash function to compute the probe sequence?
Separate Chaining
Quadratic Probing
Linear Probing
Double Hashing
What is the primary advantage of using a hashmap over a simple array for storing and retrieving data?
Hashmaps provide faster access to data based on a key, while arrays require linear search in some cases.
Hashmaps use less memory than arrays.
Hashmaps can store duplicate keys, while arrays cannot.
Hashmaps maintain data in sorted order, unlike arrays.
In a hash table using separate chaining for collision resolution, what is the worst-case time complexity for searching for an element?
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 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
A hashmap where words are keys and their frequencies are values
A sorted linked list where each node contains a word and its frequency
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 simple hash function is always preferred as it reduces computational overhead.
A complex hash function guarantees a lower collision rate, improving performance.