Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Chapter: 41
Q641:
What is a key feature of a hash table's storage in the context of hashing?
A. Data is stored in consecutive locations
B. Data is stored in sorted order
C. Data is stored based on hash indices
D. Data is stored in a linked list
Correct Answer: C
Chapter: 41
Q642:
In the hashCode function, what is done with the ASCII values of characters?
A. Added together and then modded with table size
B. Multiplied together and then modded with table size
C. Added together and then multiplied by table size
D. Multiplied together and then added to table size
Correct Answer: A
Chapter: 41
Q643:
What is a disadvantage of using a simple modulo operation for hashing?
A. It may lead to collisions if the key distribution is uneven
B. It ensures even distribution of keys
C. It results in faster retrieval times
D. It avoids gaps in array storage
Correct Answer: A
Chapter: 41
Q644:
How does an AVL tree maintain its balance?
A. By using hashing
B. By ensuring all nodes have the same height
C. By performing rotations to balance the tree
D. By sorting nodes at each level
Correct Answer: C
Chapter: 41
Q645:
Which data structure uses a table with non-consecutive storage locations for entries?
A. Linked list
B. Hash table
C. Binary search tree
D. AVL tree
Correct Answer: B
Chapter: 41
Q646:
What operation is performed by the remove method in hashing?
A. Calculate storage place and set it to null
B. Calculate storage place and retrieve the data
C. Retrieve data and remove it from the table
D. Insert new data at the calculated index
Correct Answer: A
Chapter: 42
Q647:
What is a common issue with using a hash function where T is not a prime number?
A. The hash values might be unique for all keys.
B. The hash values might be evenly distributed.
C. The hash values might collide more frequently.
D. The hash values might be always different.
Correct Answer: C
Chapter: 42
Q648:
What is a good practice to avoid collisions in hash functions?
A. Use a non-prime number for T.
B. Use a large hash table size.
C. Use a prime number for T.
D. Use multiple hash functions.
Correct Answer: C
Chapter: 42
Q649:
What problem arises when two different keys hash to the same index?
A. Collision
B. Collision Resolution
C. Linear Probing
D. Hash Table Overflow
Correct Answer: A
Chapter: 42
Q650:
What technique is used to handle collisions by finding the next available position in the array?
A. Linear Probing
B. Quadratic Probing
C. Linked List
D. Open Addressing
Correct Answer: A
Chapter: 42
Q651:
Which of the following describes Linear Probing in hash tables?
A. It uses multiple hash functions to resolve collisions.
B. It uses a linked list to handle collisions.
C. It searches for the next available slot sequentially.
D. It uses a quadratic function to resolve collisions.
Correct Answer: C
Chapter: 42
Q652:
What is the primary issue with Linear Probing in hash tables?
A. It can lead to clustering of entries.
B. It always requires more memory.
C. It is slower than using linked lists.
D. It avoids all collisions effectively.
Correct Answer: A
Chapter: 42
Q653:
In Linear Probing, what happens if you reach the end of the table and still cannot find an empty slot?
A. Wrap around to the beginning of the table.
B. Increase the size of the hash table.
C. Use a different hash function.
D. Stop searching as the table is full.
Correct Answer: A
Chapter: 42
Q654:
What method can be used to resolve collisions other than Linear Probing?
A. Quadratic Probing
B. Linked List Insertion
C. Separate Chaining
D. All of the above
Correct Answer: D
Chapter: 42
Q655:
What is the function f(i) in Linear Probing if it is defined as a linear function?
A. f(i) = i^2
B. f(i) = 2*i
C. f(i) = i
D. f(i) = 2^i
Correct Answer: C
Chapter: 42
Q656:
What is the primary advantage of using a linked list for collision resolution in hash tables?
A. It simplifies insertion and removal.
B. It avoids the need for a hash function.
C. It prevents clustering.
D. It requires less memory.
Correct Answer: A
Chapter: 43
Q657:
What is the primary purpose of hashing in data structures?
A. Sorting data
B. Managing collisions
C. Searching data
D. Storing data
Correct Answer: B
Chapter: 43
Q658:
What happens if a hash function returns the same index for different keys?
A. A collision occurs
B. The hash table overflows
C. The table is sorted
D. The data is stored in sequence
Correct Answer: A
Chapter: 43
Q659:
Which hashing collision resolution method uses the next available slot in the array?
A. Linked List Chaining
B. Quadratic Probing
C. Linear Probing
D. Double Hashing
Correct Answer: C
Chapter: 43
Q660:
What is the main disadvantage of Linear Probing in hash tables?
A. It leads to clustering
B. It requires more memory
C. It is slower than linked lists
D. It is more complex to implement
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now