Data Structures & AlgorithmsHardProduct-company MCQ pattern

A directed graph has edges 1→2, 2→3, 3→1, 3→4, 4→5, 5→6, 6→4, 6→7, 7→8. How many strongly connected components does it have?

  1. A. 8
  2. B. 2
  3. C. 4
  4. D. 3

Correct answer: C. 4

{1, 2, 3} and {4, 5, 6} are cycles, while 7 and 8 lie on no cycle and are components on their own: 4 SCCs. The edge 3→4 does not merge the two cycles because there is no way back from 4 to 3.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic