What does a hashmap store data in?
Sorted Array
Linked List
Key-Value Pairs
Binary Tree
What is a disadvantage of using a hashmap?
Cannot iterate over elements in a specific order.
Keys must be immutable.
Slow search speed.
Inability to handle collisions.
If you were designing a simple hash function for strings, which operation would likely be a core component?
Sorting the characters in the string alphabetically.
Converting characters to their ASCII codes and performing arithmetic operations.
Reversing the string.
Finding the length of the string.
What is the primary advantage of using a hashmap over a linear search in an array when searching for a specific value?
Hashmaps can store sorted data.
Hashmaps use less memory.
Hashmaps offer faster search times on average.
Hashmaps can handle duplicate values more efficiently.
Which collision resolution technique is commonly used in hashmaps?
Merge Sort
Bubble Sort
Binary Search
Separate Chaining
What is the time complexity of inserting a key-value pair into a hashmap in the average case?
O(n)
O(log n)
O(1)
O(n log n)
Which of the following data structures is commonly used to implement a hashmap?
Array
Graph
Tree
Why is a good hash function important for hashmap performance?
To ensure that keys are evenly distributed across the hash table, reducing collisions.
To reduce the memory used by the hash table.
To allow for efficient resizing of the hash table.
To minimize the number of comparisons required to find an element.
What happens when a hash function produces the same index for different keys?
The key-value pair is discarded.
A collision occurs.
The hash function is automatically updated.
The hashmap raises an error.
How are dictionaries typically implemented in programming languages?
Using arrays for efficient indexing.
Using linked lists for fast insertions.
Using binary trees for sorted key storage.
Using hashmaps to provide fast key-value lookups.