What is a key advantage of using a hashmap over a sorted array for searching?
Hashmaps allow duplicate keys.
Hashmaps consume less memory.
Hashmaps offer faster search on average.
Hashmaps maintain data in sorted order.
Which of the following is NOT a collision handling technique in hashmaps?
Open Addressing
Binary Search
Separate Chaining
Linear Probing
Which of these data structures is commonly used to handle collisions in hashmaps?
Queue
Linked List
Heap
Binary Tree
In hashmap terminology, what does a 'bucket' typically refer to?
The load factor of the hashmap.
An individual element within the hashmap's array.
The range of possible hash values produced by the hash function.
A linked list or other data structure used to handle collisions.
What is the primary role of the modulo operator (%) in simple hash functions?
To map the hash code to a valid index within the array's bounds.
To handle collisions effectively.
To sort keys in ascending order based on their hash values.
To generate a unique hash code for each key.
In hashmap terminology, what does 'collision' refer to?
When two hashmaps have the same size.
When trying to delete a key that doesn't exist.
When a hash function produces the same output for all inputs.
When two keys map to the same index in the hashmap.
What is a disadvantage of using hashmaps when the number of elements to be stored is not known in advance?
They might require resizing, which can be an expensive operation.
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 are more complex to implement than linked lists.
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 distribute keys uniformly across the hash table.
It should be deterministic (same input always yields the same output).
Why are hash functions typically designed to be fast to compute?
To ensure efficient insertion, deletion, and search operations.
To maintain the sorted order of keys.
To prevent data loss during collisions.
To minimize memory usage.
You want to update the value associated with a key in a hashmap. What is the general process involved?
Search for the key sequentially, and update the value when found.
Calculate the hash of the key, find the corresponding bucket, and directly modify the value.
Delete the existing key-value pair, then insert a new one with the updated value.
Hashmaps do not support value updates; you need to create a new hashmap.