UGC-NET Jun 2019 · Graph Traversals (BFS & DFS)

MCQ · 2 marks · Problem PROG-GRPH-0005

Which of the following is application of depth-first search?
  1. A
    Only topological sort
  2. B
    Only strongly connected components
  3. C
    Both topological sort and strongly connected components
  4. D
    Neither topological sort nor strongly connected components

Solve it on GATE DA practice →More Graph Theory & Algorithms problems

Show the worked solutionBoth are classic DFS applications.Topological sort: run DFS on the DAG and list the vertices in decreasing order of finishing time.Strongly connected components (Kosaraju): run DFS on \(G\) to get finishing times, then DFS on the transpose \(G^T\) in decreasing finishing order; each tree of the second DFS is one SCC (Tarjan's algorithm is also a single DFS).So DFS is used for both.Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com