Question

If GG is a forest with nn vertices and kk connected components, how many edges does GG have?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2014 answer key

Solution

Sum the edge counts across all connected components of an acyclic graph.

  1. A forest is defined as an undirected acyclic graph.

  2. Each connected component of a forest is a tree.

  3. Let kk be the number of connected components, and let nin_i denote the number of vertices in component ii for 1≤i≤k1 \le i \le k.

    • The sum of vertices over all components is:
      ∑i=1kni=n.\sum_{i=1}^k n_i = n.
  4. For any tree with nin_i vertices, the number of edges is exactly ni−1n_i - 1.

  5. Summing edges across all kk trees:

    Total Edges=∑i=1k(ni−1)=∑i=1kni−∑i=1k1=n−k.\text{Total Edges} = \sum_{i=1}^k (n_i - 1) = \sum_{i=1}^k n_i - \sum_{i=1}^k 1 = n - k.

This matches option C (n−kn - k).

Final answer

C

Common trap

Using the tree formula n - 1 instead of subtracting k for a forest with k components.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 3
Question
61 of 65, printed as CS Q.51
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.