Question

The number of edges present in the forest generated by the DFS traversal of an undirected graph GG with 100 vertices is 40. The number of connected components in GG is _________

Official answer and solution
Official answer
60
From
Official GATE 2024 answer key

Solution

Use the forest relation Eforest=V−CE_{\text{forest}} = V - C, where VV is the number of vertices and CC is the number of connected components (trees in the DFS forest).

A DFS traversal of an undirected graph GG with VV vertices and CC connected components produces a spanning forest consisting of CC trees and Eforest=V−CE_{\text{forest}} = V - C tree edges. Given V=100V = 100 and Eforest=40E_{\text{forest}} = 40:

C=V−Eforest=100−40=60C = V - E_{\text{forest}} = 100 - 40 = 60
Final answer

60

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

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
Question
60 of 65
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.