The most appropriate matching for the following pairs is: X: Depth-first…

2000

The most appropriate matching for the following pairs is:

X: Depth-first search -> 1: Heap
Y: Breadth-first search -> 2: Queue
Z: Sorting -> 3: Stack

  1. A.

    X-1, Y-2, Z-3

  2. B.

    X-3, Y-1, Z-2

  3. C.

    X-3, Y-2, Z-1

  4. D.

    X-2, Y-3, Z-1

Attempted by 41 students.

Show answer & explanation

Correct answer: C

Depth-first search (DFS) explores as far as possible along a path before backtracking, so it is naturally implemented using a stack. Thus X matches 3.

Breadth-first search (BFS) visits vertices level by level, so it uses a queue. Thus Y matches 2.

Heap-based sorting, such as heapsort, uses a heap data structure. Thus Z matches 1.

Therefore the correct matching is X-3, Y-2, Z-1.

Explore the full course: Gate Guidance By Sanchit Sir