GATE CS 2024 Set 1 — Question 60

NAT+2 / -0EasyDFS TraversalGraphs (Data Structure)Programming & Data StructuresConnected Components

Programming & Data Structures → Graphs (Data Structure) → Connected Components

Last updated

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 _________

Correct answer

60 to 60

Solution

In an undirected graph with nn vertices and kk connected components, any spanning forest (including one generated by DFS) will have exactly nkn - k edges.
Given:
  • Number of vertices (nn) = 100
  • Number of edges in the DFS forest = 40
Calculation:
Using the formula for the number of edges in a forest:Number of edges=nk\text{Number of edges} = n - k40=100k40 = 100 - kk=10040=60k = 100 - 40 = 60Therefore, the number of connected components in GG is 60.

More questions on Graphs (Data Structure)

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free