What is the primary reason for using a prime number as the size of a hash table in many implementations?
To make the implementation of the hash table simpler.
To ensure an even distribution of keys across the hash table, reducing collisions.
To increase the speed of hash function computation.
To minimize the memory usage of the hash table.
In cuckoo hashing, how many hash functions are typically used?
3
1
2
It depends on the size of the hash table.
In the context of amortized analysis of hash table operations, what does the term "amortized" refer to?
The average time complexity of an operation over a sequence of operations.
The time complexity of an operation when the hash table is full.
The worst-case time complexity of an operation.
The best-case time complexity of an operation.
What security risk arises from storing sensitive data like passwords directly in a hashmap, even when hashed?
Hashmaps are inherently less secure than other data structures for storing passwords.
An attacker gaining access to the hashmap could retrieve the plaintext passwords.
Storing any data in a hashmap increases the risk of SQL injection attacks.
Hash collisions could allow attackers to bypass authentication.
What is the primary advantage of using a universal hash function?
It provides better performance than any single, fixed hash function.
It eliminates the possibility of collisions entirely.
It ensures constant-time performance for all operations.
It makes the hash table resistant to attacks that exploit patterns in the hash function.
In a web server implemented using a hashmap to store cached web pages, which collision resolution strategy is generally preferred for its performance in handling a high volume of concurrent requests?
Double Hashing
Open Addressing with linear probing
Separate Chaining with linked lists
Separate Chaining with balanced binary search trees
In Python, what is the purpose of the __hash__ method when used in conjunction with dictionaries?
__hash__
To provide a mechanism for iterating over the key-value pairs in the dictionary.
To specify how a custom object should be converted into a hash value for use as a key.
To determine the maximum number of elements that can be stored in the dictionary before resizing.
To define a custom sorting order for keys in the dictionary.
Hopscotch hashing aims to improve the performance of open addressing by:
Employing a binary search tree for efficient collision resolution.
Limiting the maximum distance a key can be placed from its original hash index.
Using multiple hash tables to store keys with different hash values.
Using a dynamic array to resize the table when the load factor gets high.
Which of these statements best describes the advantage of using a perfect hash function over a regular hash function?
It eliminates the need for collision handling.
It guarantees constant-time search, insertion, and deletion in the worst case.
It allows for faster key insertions.
It reduces the memory used by the hash table.
In a hash table using double hashing, the second hash function is used to:
Determine the step size for probing in case of a collision.
Calculate the size of the hash table.
Determine the initial index to store the key.
Generate a new key if a collision occurs.