Data Structures & AlgorithmsModerateGATE CS

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

  1. A. 36
  2. B. 74
  3. C. 42
  4. D. 45

Correct answer: D. 45

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic