Which of these data structures can provide a more secure and performant alternative to a hashmap when handling user authentication data, especially in scenarios prone to hash flooding attacks?
Array
Queue
Tree
Linked list
In Python, what is the purpose of the __hash__ method when used in conjunction with dictionaries?
__hash__
To determine the maximum number of elements that can be stored in the dictionary before resizing.
To specify how a custom object should be converted into a hash value for use as a key.
To define a custom sorting order for keys in the dictionary.
To provide a mechanism for iterating over the key-value pairs in the dictionary.
In cuckoo hashing, how many hash functions are typically used?
3
It depends on the size of the hash table.
2
1
What is the primary advantage of using a universal hash function?
It makes the hash table resistant to attacks that exploit patterns in the hash function.
It ensures constant-time performance for all operations.
It eliminates the possibility of collisions entirely.
It provides better performance than any single, fixed hash function.
Which of the following statements accurately describes a key difference in the behavior of Python dictionaries and Java HashMaps?
Java HashMaps allow null keys and values, while Python dictionaries do not.
Python dictionaries use separate chaining for collision resolution, while Java HashMaps employ open addressing.
Java HashMaps are synchronized and thread-safe, whereas Python dictionaries are not.
Python dictionaries maintain insertion order, while Java HashMaps do not guarantee any specific order.
You are designing a system to store and retrieve frequently accessed data with high performance. Which of the following hash table collision resolution strategies would generally offer the BEST performance under high load factors?
Double Hashing
Separate Chaining
Linear Probing
Quadratic Probing
Which of these statements best describes the advantage of using a perfect hash function over a regular hash function?
It reduces the memory used by the hash table.
It guarantees constant-time search, insertion, and deletion in the worst case.
It eliminates the need for collision handling.
It allows for faster key insertions.
Why is it generally recommended to avoid using mutable objects as keys in hash tables?
Using mutable keys increases the memory overhead of the hash table.
Hash tables cannot store mutable objects as keys; only immutable objects are allowed.
Mutable keys can lead to inconsistent state if their values are modified after being inserted into the hash table.
Mutable keys make the implementation of the hash table significantly more complex.
In a hashmap implementation using open addressing with linear probing, what is the worst-case time complexity for searching for a key if the hash table is nearly full?
O(log n)
O(n log n)
O(1)
O(n)
Hopscotch hashing aims to improve the performance of open addressing by:
Using multiple hash tables to store keys with different hash values.
Limiting the maximum distance a key can be placed from its original hash index.
Using a dynamic array to resize the table when the load factor gets high.
Employing a binary search tree for efficient collision resolution.