Data Structures & AlgorithmsHardInfosys · Graphs

An undirected graph on vertices 0 to 9 has the edges (0,1), (1,2), (2,0), (3,4), (5,6), (6,7), (7,5) and a self-loop (8,8). How many connected components does it have?

  1. A. 5
  2. B. 3
  3. C. 4
  4. D. 6

Correct answer: A. 5

The components are {0,1,2}, {3,4}, {5,6,7}, and the single vertices {8} and {9}.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic