Data Structures & AlgorithmsModerateGATE CS · Product-company placement

A simple undirected graph has 9 vertices and exactly 4 connected components. What is the maximum possible number of edges?

  1. A. 10
  2. B. 15
  3. C. 32
  4. D. 12

Correct answer: B. 15

Put 3 isolated vertices aside and make the remaining 6 vertices a complete graph: C(6, 2) = 15. Splitting vertices more evenly across components always gives fewer edges.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic