Data Structures & AlgorithmsHardGATE CS · ICPC regional · Product Company SDE

A forest has 27 vertices and 2 connected components (trees). How many edges does it have?

  1. A. 25
  2. B. 27
  3. C. 20
  4. D. 38

Correct answer: A. 25

Each tree has (vertices − 1) edges, so the forest has 27 − 2 = 25.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic