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
Using a hash function that distributes keys evenly across the hash table
Storing keys with a wide range of values
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
Degraded performance due to chaining or open addressing for collision resolution
Complexity in implementing the hash function itself
Increased memory usage due to the fixed size allocation
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.
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.
A well-chosen hash function minimizes collisions, leading to faster lookups and insertions.
When does rehashing typically occur in a hashmap?
When the load factor exceeds a predetermined threshold.
When the hashmap is cleared using the clear() method.
Every time a new key is inserted.
When the hash function is modified.
Which collision resolution strategy is generally preferred for hash tables with open addressing when the load factor is low?
Linear Probing
Separate Chaining
Double Hashing
Quadratic Probing
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 + 4) % m
(i + 1) % m
(i * 2) % m
What is the significance of the output size of a cryptographic hash function?
Affects the uniqueness of the hash for different inputs
Determines the speed of hash computation
Impacts the resistance against brute-force attacks
Influences the memory required to store the hash function
Which collision resolution technique involves using a second, independent hash function to compute the probe sequence?
In a hash table using separate chaining for collision resolution, what is the worst-case time complexity for searching for an element?
O(1)
O(n log n)
O(log n)
O(n)
You are implementing an LRU (Least Recently Used) cache. Which data structure, in conjunction with a hashmap, is most suitable for tracking the usage order of cached items?
Stack
Queue
Doubly Linked List
Binary Tree