GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A DAG on vertices 1–8 has edges 1→2, 1→3, 2→4, 3→4, 4→5, 4→6, 5→7, 6→7, 3→8, 8→7. How many different topological orderings does it have?
- A. 12
- B. 16
- C. 24
- D. 18
Correct answer: D. 18
Vertex 1 must come first and 7 last; 4 needs both 2 and 3, 5 and 6 need 4, and 8 only needs 3. Counting linear extensions by dynamic programming over subsets of already-placed vertices gives 18 (checked by exhaustive count).
More Algorithms questions
- 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…
- 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…