What is a key advantage of using a hashmap over a sorted array for searching?
Hashmaps allow duplicate keys.
Hashmaps maintain data in sorted order.
Hashmaps consume less memory.
Hashmaps offer faster search on average.
What is linear probing in the context of open addressing for collision resolution?
Using a linked list to store colliding elements at the same index.
Resizing the hash table to accommodate more elements.
Using a different hash function to avoid collisions.
Probing for an empty slot by sequentially searching from the collision index.
Which collision resolution technique is commonly used in hashmaps?
Bubble Sort
Merge Sort
Binary Search
Separate Chaining
Which of these is a disadvantage of open addressing compared to separate chaining in hashmaps?
Cannot handle a large number of collisions efficiently.
Clustering of elements can lead to performance degradation.
Increased memory usage due to linked lists.
Requires more complex implementation compared to chaining.
A simple hash function for strings could involve summing the ASCII values of each character in the string. What is a potential drawback of this approach?
It can lead to a high number of collisions for anagrams.
It's computationally expensive.
It's not reversible, meaning you can't get the original string from the hash.
It can't handle strings of varying lengths.
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 time complexity, in the average case, for searching for a key in a well-implemented hashmap?
O(n log n)
O(log n)
O(n)
O(1)
Which characteristic of a hash function is undesirable and can lead to performance degradation?
Deterministic
Fast Computation
Uniform Distribution
High Collision Rate
What is the time complexity of inserting a key-value pair into a hashmap in the average case?
Why is a good hash function important for hashmap performance?
To minimize the number of comparisons required to find an element.
To allow for efficient resizing of the hash table.
To ensure that keys are evenly distributed across the hash table, reducing collisions.
To reduce the memory used by the hash table.