Data Structures MCQs with Answers
Practice important Data Structures MCQs with answers and explanations.
Multiple Choice Questions
Q581: What is the worst-case height of a tree using Union by Size for n nodes?
- A: n
- B: log2(n)
- C: n log n
- D: O(1)
View Answer
B
Q582: In Union by Height, which tree becomes the root when merging two trees?
- A: The tree with the greater height
- B: The tree with fewer nodes
- C: The tree with the lesser height
- D: The tree with more nodes
View Answer
A
Q583: What is the key advantage of using Union by Size over a simple union approach?
- A: It ensures that the resulting trees are balanced and shallow
- B: It allows trees to be merged without comparing sizes
- C: It directly affects the find operation
- D: It reduces the complexity of the union operation
View Answer
A
Q584: What does the union operation do in the context of disjoint sets?
- A: Links two sets
- B: Finds the representative of a set
- C: Splits a set into smaller sets
- D: Merges two trees into one set
View Answer
A
Q585: In image segmentation, what does a pixel value of 255 represent?
- A: Black
- B: White
- C: Gray
- D: Red
View Answer
B
Q586: Which algorithm is used for maze generation as per the content?
- A: Depth-First Search
- B: Union-Find
- C: Prim's Algorithm
- D: Dijkstra's Algorithm
View Answer
B
Q587: What is the primary purpose of path optimization in the find method of disjoint sets?
- A: To increase tree size
- B: To reduce tree traversal time
- C: To improve union operation
- D: To split trees efficiently
View Answer
B
Q588: When using a threshold of 4 for binary image conversion, which value is replaced by 1?
- A: Values less than 4
- B: Values equal to 4
- C: Values more than 4
- D: All values between 0 and 4
View Answer
C
Q589: In the pseudo code for maze generation, what operation is performed when two cells are already in the same set?
- A: Remove the wall between them
- B: Do nothing
- C: Add a new wall between them
- D: Combine the cells into one set
View Answer
B
Q590: What is a Table ADT primarily used to represent?
- A: Single dimension data
- B: Two-dimensional data
- C: Graphs and trees
- D: Unordered lists
View Answer
B