The most appropriate matching for the following pairs
is:
View worked solution
Answer: C
We can match the algorithms with their primary associated data structures as follows:
- X: Depth First Search (DFS) explores as deep as possible along each branch before backtracking. This backtracking behavior is naturally implemented using a Stack (LIFO structure), either explicitly or implicitly via recursion.
- Y: Breadth First Search (BFS) explores the neighbor nodes first before moving to the next level of neighbors. This level-order traversal is implemented using a Queue (FIFO structure).
- Z: Sorting can be efficiently performed using a Heap data structure (specifically, Heapsort, which has a time complexity of ).
Therefore, the correct matching is X - 3, Y - 2, Z - 1, which corresponds to Option C.
Free practice · Your answers on this page are not saved.
