GATE Computer ScienceHardGATE CS (PYQ pattern)
A DFS on a directed graph processes vertices in alphabetical order and each adjacency list in alphabetical order. Edges: A→B, A→C, A→E, B→D, B→E, C→D, D→A, D→E, E→C, F→E, F→G, G→F. How many edges are neither tree edges nor back edges (that is, forward or cross edges)?
- A. 3
- B. 4
- C. 5
- D. 2
Correct answer: B. 4
DFS from A visits A, B, D, E, C (tree edges AB, BD, DE, EC); back edges are D→A, C→D and G→F. Forward edges are A→C, A→E and B→E, and F→E is a cross edge (E already finished, discovered earlier): 3 + 1 = 4.
More Algorithms questions
- A directed graph on A–K has edges A→B, B→C, C→A, C→D, D→E, E→F, F→D, G→F, G→H, H→I, I→G, B→H, E→J, K→J, K→A. Let s be its number of…
- The directed graph on vertices A–K has edges A→B, B→A, C→D, D→C, E→F, F→G, G→E, A→H, C→H, E→H, H→I, H→J, I→K, J→K, B→J. What is the…
- An undirected graph has vertices 0–11 and edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3, 5-6, 6-7, 7-8, 8-6, 1-9, 9-10, 10-1, 4-11. Let a be its…
- A flow network has edges s→a 10, s→b 8, a→c 4, a→d 3, b→d 5, b→c 2, a→b 3, c→t 9, d→t 8; its maximum flow value is 14. How many different…
- A network has capacities s→u 100, s→v 50, u→v 1, u→t 50, v→t 100. Ford–Fulkerson may choose ANY augmenting path in the residual graph…
- A bipartite graph has left vertices L0–L8 and right vertices R0–R6, with adjacency L0:{R0}, L1:{R0,R1}, L2:{R0,R1}, L3:{R0,R1}…