Q. If a hash table has a load factor of 0.75, what does this imply?
-
A.
The table is full
-
B.
The table is half full
-
C.
The table is 75% full
-
D.
The table has 75 entries
Solution
A load factor of 0.75 means that the hash table is 75% full, indicating the ratio of the number of entries to the number of slots in the table.
Correct Answer:
C
— The table is 75% full
Learn More →
Q. If a hash table has a load factor of 0.75, what does this mean?
-
A.
The table is full
-
B.
75% of the table is empty
-
C.
75% of the table is filled with elements
-
D.
The table can only hold 75 elements
Solution
A load factor of 0.75 means that 75% of the hash table's capacity is filled with elements, indicating how full the table is.
Correct Answer:
C
— 75% of the table is filled with elements
Learn More →
Q. In a hash table, what is the purpose of a hash function?
-
A.
To sort the data
-
B.
To convert keys into indices
-
C.
To store data in a linked list
-
D.
To manage memory allocation
Solution
The hash function converts keys into indices, allowing for efficient data retrieval in the hash table.
Correct Answer:
B
— To convert keys into indices
Learn More →
Q. What is a potential drawback of using a hash table?
-
A.
It requires more memory than arrays
-
B.
It is slower than binary search trees
-
C.
It cannot handle dynamic data
-
D.
It is not suitable for large datasets
Solution
Hash tables can require more memory than arrays due to the need for additional space to handle collisions and maintain performance.
Correct Answer:
A
— It requires more memory than arrays
Learn More →
Q. What is the average time complexity for searching an element in a hash table?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(1)
-
D.
O(n^2)
Solution
The average time complexity for searching an element in a hash table is O(1) due to the direct access provided by the hash function.
Correct Answer:
C
— O(1)
Learn More →
Q. Which of the following hash functions is considered a good practice?
-
A.
Using the identity function
-
B.
Using a simple modulus operation
-
C.
Using a complex mathematical function
-
D.
Using a random number generator
Solution
A good hash function should distribute keys uniformly across the hash table, and using a simple modulus operation is a common practice.
Correct Answer:
B
— Using a simple modulus operation
Learn More →
Q. Which of the following hash functions is considered good practice?
-
A.
A function that returns the key itself
-
B.
A function that uses a prime number
-
C.
A function that always returns the same index
-
D.
A function that is linear
Solution
A good hash function often uses a prime number to help distribute keys uniformly across the hash table.
Correct Answer:
B
— A function that uses a prime number
Learn More →
Q. Which of the following is a common method for handling collisions in a hash table?
-
A.
Chaining
-
B.
Sorting
-
C.
Binary Search
-
D.
Recursion
Solution
Chaining is a common collision resolution technique where each slot in the hash table points to a linked list of entries that hash to the same index.
Correct Answer:
A
— Chaining
Learn More →
Showing 1 to 8 of 8 (1 Pages)