Q. How can the performance of a hash table be improved?
A.
By using a larger initial size
B.
By using a simpler hash function
C.
By reducing the number of entries
D.
By avoiding resizing
Show solution
Solution
Using a larger initial size can help reduce the load factor and improve performance by minimizing collisions and the need for resizing.
Correct Answer:
A
— By using a larger initial size
Learn More →
Q. If a hash table uses a hash function that produces a large number of collisions, what is the likely outcome?
A.
Increased search time
B.
Decreased memory usage
C.
Faster insertions
D.
No effect on performance
Show solution
Solution
A hash function that produces many collisions will lead to increased search times as more entries must be checked to find a specific key.
Correct Answer:
A
— Increased search time
Learn More →
Q. In a hash table, what happens when the load factor exceeds a certain threshold?
A.
The table is resized and rehashed
B.
The table becomes immutable
C.
All entries are deleted
D.
The hash function is changed
Show solution
Solution
When the load factor exceeds a certain threshold, the hash table is typically resized and all existing entries are rehashed to maintain efficient access times.
Correct Answer:
A
— The table is resized and rehashed
Learn More →
Q. In a hash table, what is the effect of a poor hash function?
A.
Increased memory usage
B.
Faster access times
C.
Higher collision rates
D.
Simpler implementation
Show solution
Solution
A poor hash function can lead to higher collision rates, which degrades the performance of the hash table.
Correct Answer:
C
— Higher collision rates
Learn More →
Q. What is a potential issue with using a poor hash function?
A.
Increased memory usage
B.
Faster access times
C.
Higher collision rates
D.
Easier debugging
Show solution
Solution
A poor hash function can lead to higher collision rates, which degrades the performance of the hash table and increases the time complexity for operations.
Correct Answer:
C
— Higher collision rates
Learn More →
Q. What is the ideal load factor for a hash table to maintain efficient performance?
A.
0.1
B.
0.5
C.
1.0
D.
2.0
Show solution
Solution
An ideal load factor is typically around 0.5, balancing space and time efficiency while minimizing collisions.
Correct Answer:
B
— 0.5
Learn More →
Q. What is the main disadvantage of using open addressing for collision resolution?
A.
It requires more memory
B.
It can lead to clustering
C.
It is slower than chaining
D.
It cannot handle deletions
Show solution
Solution
Open addressing can lead to clustering, where a group of consecutive slots are filled, which can degrade performance during searches and insertions.
Correct Answer:
B
— It can lead to clustering
Learn More →
Q. What is the purpose of a hash function in a hash table?
A.
To sort the data
B.
To encrypt the data
C.
To map keys to indices
D.
To store data in a binary tree
Show solution
Solution
The hash function's purpose is to map keys to indices in the hash table, allowing for efficient data retrieval.
Correct Answer:
C
— To map keys to indices
Learn More →
Q. Which of the following hash functions is considered good for a hash table?
A.
A function that always returns the same index
B.
A function that distributes keys uniformly across the table
C.
A function that uses only the first character of the key
D.
A function that is computationally expensive
Show solution
Solution
A good hash function distributes keys uniformly across the hash table to minimize collisions and ensure efficient access.
Correct Answer:
B
— A function that distributes keys uniformly across the table
Learn More →
Q. Which of the following hash functions is least likely to produce collisions?
A.
Simple modulus operation
B.
Multiplicative hashing
C.
Cryptographic hash functions
D.
Division by a prime number
Show solution
Solution
Cryptographic hash functions are designed to minimize collisions and provide a uniform distribution of hash values.
Correct Answer:
C
— Cryptographic hash functions
Learn More →
Q. Which of the following is NOT a type of hash table?
A.
Separate chaining hash table
B.
Open addressing hash table
C.
Dynamic array hash table
D.
Cuckoo hash table
Show solution
Solution
Dynamic array hash table is not a recognized type of hash table; the other options are valid methods for implementing hash tables.
Correct Answer:
C
— Dynamic array hash table
Learn More →
Q. Which of the following scenarios is best suited for using a hash table?
A.
When order of elements is important
B.
When frequent insertions and deletions are required
C.
When searching for elements by key is needed
D.
When elements need to be sorted
Show solution
Solution
Hash tables are ideal for scenarios where fast searching by key is required, as they provide average O(1) time complexity for lookups.
Correct Answer:
C
— When searching for elements by key is needed
Learn More →
Showing 1 to 12 of 12 (1 Pages)