What is a significant disadvantage of using a fixed-size hash table in conjunction with a hash function prone to collisions?
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
Inability to store data that exceeds the pre-defined table size
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
Two arrays: one for storing words and one for storing their frequencies
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
When choosing a collision resolution strategy for a hash table, which factors are essential to consider?
Size of the keys and values being stored
Programming language and hardware architecture
Expected data distribution and load factor
All of the above
In a hash table using separate chaining for collision resolution, what is the worst-case time complexity for searching for an element?
O(log n)
O(n)
O(n log n)
O(1)
Which of the following scenarios could potentially lead to collisions in a hashmap?
Storing keys with a wide range of values
Using a hash function that distributes keys evenly across the hash table
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
You need to identify the first non-repeating character in a string. How can a hashmap be utilized to solve this problem efficiently?
Store the frequency of each character in the hashmap, then iterate through the string and return the first character with a frequency of 1.
Store the characters of the string as keys in the hashmap, and their positions as values. The first character with the lowest position value is the first non-repeating character.
Use the hashmap to store the unique characters of the string, then iterate through the hashmap to find the first non-repeating character.
A hashmap cannot be used efficiently for this problem.
What is the significance of the output size of a cryptographic hash function?
Determines the speed of hash computation
Affects the uniqueness of the hash for different inputs
Influences the memory required to store the hash function
Impacts the resistance against brute-force attacks
In a web server, which scenario is best suited for using a hashmap to optimize performance?
Storing and retrieving static website content like images and CSS files
Storing and retrieving user session data
Maintaining a log of all incoming requests in chronological order
Managing the order of user connections to ensure fairness
What advantage does separate chaining have over open addressing techniques in hash table collision resolution?
Faster search times at high load factors
Lower memory overhead
Handles load factors greater than 1 gracefully
Simpler implementation
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.
By simply removing the element, leaving the slot empty.
Deletions are not allowed in hashmaps with open addressing.
By marking the slot as "deleted" and implementing a mechanism to handle such markers during search and insertion.