GATE / CS ARCHIVE

GATE CSE 1992 / QUESTION 3(iii)

Edges in a forest

Discrete Mathematics · Trees & Connectivity · Full GATE CSE 1992 paper

GATE 1992, Q3(iii) Descriptive
Report issue

Trees & Connectivity

Question 3(iii), GATE 1992: A forest has n vertices and p connected components. How many edges?
Question 3(iii), GATE 1992: A forest has n vertices and p connected components. How many edges?
Tap to enlarge
Answer & solution

Answer: n−p (no official key was published)

Every component of a forest is a tree. If component i has ni vertices, it has ni−1 edges. Summing over the p components gives Σ(ni−1)=Σni−p=n−p. Isolated vertices count as one-vertex components with zero edges, so the formula handles them automatically. The acyclicity assumption is essential: a graph with cycles can have more edges with the same n and p. The empty forest gives zero with n=p=0.

Original paper, page 5