StreakPeaked· Practice

ExamsGATETechnical

If G is a forest with n vertices and k connected components, how many edges does G have?

  1. ⌈n/k⌉
  2. ⌊n/k⌋
  3. n − k
  4. n − k + 1

Correct answer: n − k

Solution

In a forest, which is a collection of trees, the number of edges is always one less than the number of vertices in each connected component. Therefore, for k components, the total number of edges is n (the total number of vertices) minus k (the number of components), resulting in n - k.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →