Similar questions 1 more → · asked again: GATE 2014 Set 3, Q51
Trees & Connectivity


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.