Which of the following operations typically has a time complexity of O(n) in the worst case for a hashmap?
Insertion
Deletion
Search
All of the above
What is a significant disadvantage of using a hashmap when you need to retrieve elements in a sorted order?
Hashmaps cannot handle duplicate values.
Hashmaps don't inherently maintain order.
Hashmaps have high memory consumption.
Hashmaps have slow insertion times.
What is the time complexity, in the average case, for searching for a key in a well-implemented hashmap?
O(log n)
O(n log n)
O(n)
O(1)
What happens when a hash function produces the same index for different keys?
The hash function is automatically updated.
A collision occurs.
The hashmap raises an error.
The key-value pair is discarded.
What is the purpose of a load factor in a hashmap?
To store the maximum number of key-value pairs.
To measure the efficiency of the hash function.
To count the number of collisions.
To determine when to resize the hashmap.
Why is a good hash function important for hashmap performance?
To allow for efficient resizing of the hash table.
To minimize the number of comparisons required to find an element.
To reduce the memory used by the hash table.
To ensure that keys are evenly distributed across the hash table, reducing collisions.
Which of these is NOT a desirable property of a good hash function?
It should be computationally expensive to calculate.
It should minimize collisions as much as possible.
It should be deterministic (same input always yields the same output).
It should distribute keys uniformly across the hash table.
You want to update the value associated with a key in a hashmap. What is the general process involved?
Hashmaps do not support value updates; you need to create a new hashmap.
Search for the key sequentially, and update the value when found.
Delete the existing key-value pair, then insert a new one with the updated value.
Calculate the hash of the key, find the corresponding bucket, and directly modify the value.
Which collision resolution technique is commonly used in hashmaps?
Bubble Sort
Merge Sort
Binary Search
Separate Chaining
What is the time complexity of inserting a key-value pair into a hashmap in the average case?