Which of the following operations typically has a time complexity of O(n) in the worst case for a hashmap?
Deletion
Insertion
Search
All of the above
What is a disadvantage of using hashmaps when the number of elements to be stored is not known in advance?
They are not suitable for storing data in a sorted order.
They are less memory-efficient than arrays for storing a fixed number of elements.
They might require resizing, which can be an expensive operation.
They are more complex to implement than linked lists.
What is the primary role of the modulo operator (%) in simple hash functions?
To sort keys in ascending order based on their hash values.
To generate a unique hash code for each key.
To handle collisions effectively.
To map the hash code to a valid index within the array's bounds.
What is the primary advantage of using a hashmap over a linear search in an array when searching for a specific value?
Hashmaps can handle duplicate values more efficiently.
Hashmaps use less memory.
Hashmaps offer faster search times on average.
Hashmaps can store sorted data.
You want to update the value associated with a key in a hashmap. What is the general process involved?
Delete the existing key-value pair, then insert a new one with the updated value.
Search for the key sequentially, and update the value when found.
Hashmaps do not support value updates; you need to create a new hashmap.
Calculate the hash of the key, find the corresponding bucket, and directly modify the value.
Which of the following is NOT a typical operation supported by hashmaps?
Sort
Delete
Insert
What is a significant disadvantage of using a hashmap when you need to retrieve elements in a sorted order?
Hashmaps don't inherently maintain order.
Hashmaps have high memory consumption.
Hashmaps have slow insertion times.
Hashmaps cannot handle duplicate values.
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 are hash functions typically designed to be fast to compute?
To prevent data loss during collisions.
To ensure efficient insertion, deletion, and search operations.
To minimize memory usage.
To maintain the sorted order of keys.
What is a disadvantage of using a hashmap?
Slow search speed.
Inability to handle collisions.
Cannot iterate over elements in a specific order.
Keys must be immutable.