GATE Computer ScienceModerateGATE CS (PYQ pattern)
An undirected graph has 14 vertices, 20 edges and exactly 3 connected components. DFS is restarted from an unvisited vertex until all vertices are visited. How many tree edges and how many back edges does the DFS forest have, and what is the minimum number of edges whose removal leaves no cycle?
- A. 13 tree, 7 back, 7 removals
- B. 11 tree, 9 back, 9 removals
- C. 11 tree, 9 back, 7 removals
- D. 11 tree, 7 back, 9 removals
Correct answer: B. 11 tree, 9 back, 9 removals
A DFS forest has one tree per component, so 14 - 3 = 11 tree edges; in an undirected DFS every non-tree edge is a back edge: 20 - 11 = 9. Removing exactly those 9 leaves a spanning forest, and no fewer suffice because E - V + c = 20 - 14 + 3 = 9 independent cycles exist. Assuming a connected graph gives 13 and 7.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A complete binary tree stored in an array has 1000 nodes. What is its height (a single node has height 0) and how many nodes are at the…
- A binary tree with 25 nodes has two pointer fields per node. How many of these 50 fields hold NULL, and how many hold NULL if the tree is…
- A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the…
- Convert the infix expression a - b c / d + e (f - g) / h (all binary operators left-associative; and / bind tighter than + and -) to…
- Evaluate the prefix expression - + 4 5 - 9 3 / 20 + 2 3 (integer division truncating toward zero).
- Under the uniform-hashing assumption, a linear-probing table has load factor 0.5. Using the Knuth approximations, the expected number of…