Data Structures & AlgorithmsVery hardGATE CS

A directed graph on A–H has edges A→C, A→D, A→H, B→G, B→H, D→E, E→A, E→B, G→F, H→C, H→E. How many strongly connected components does it have, and what is the minimum number of edges that must be added to make the whole graph strongly connected?

  1. A. 4 SCCs, 3 edges
  2. B. 3 SCCs, 2 edges
  3. C. 4 SCCs, 1 edge
  4. D. 4 SCCs, 2 edges

Correct answer: D. 4 SCCs, 2 edges

The SCCs are ABDEH | C | F | G. In the condensation DAG count sources (in-degree 0) and sinks (out-degree 0); the answer is max(sources, sinks) = 2.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic