GATE / CS ARCHIVE

SIMILAR QUESTIONS / ALGORITHMS

Test proposed topological orders against edges

2 questions solved the same way, newest first. Back to Algorithms

How these are solved

Each supplied directed acyclic graph is checked by requiring every arc tail before its head in the proposed sequence. Different graph topology and offered sequences remain essential.

1 mark · MCQ
Report issue

Graph Algorithms

Question 13, GATE 2014: A directed graph has vertices P,Q,R,S and exactly the edges P→Q, P→R, R→Q, S→R, S→Q. Which statement holds? A: No topological ordering exists. B: Both PQRS and SRQP are topological orderings. C: Both PSRQ and SPRQ are topological orderings. D: PSRQ is the only topological ordering.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (2 orders)

1. Method and setup. Topological order must place the tail of every edge before its head. Initially P and S have indegree zero. Both must precede R, and R must precede Q. There is no edge imposing an order between P and S, so either may appear first.

2. Work through the result and its assumptions. The edges require P and S before R, and R before Q; there is also P→Q and S→Q. P and S may occur in either order, giving exactly PSRQ and SPRQ. Thus C.

Original paper, page 10 · Answer key

1 mark · MCQ
Report issue

Invalid topological order

Graph Algorithms

Question 5, GATE 2007: The directed acyclic graph has V={1,2,3,4,5,6} and edges 1→2, 1→3, 2→4, 3→4, 2→5, 4→5, 3→6, 4→6. Which sequence is NOT a topological ordering?
Options:
(A) 1,2,3,4,5,6
(B) 1,3,2,4,5,6
(C) 1,3,2,4,6,5
(D) 3,2,4,1,6,5
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step through it (4 options)

1. Approach. A topological ordering places the tail of every directed edge before its head. It suffices to find one violated edge to reject an ordering.

2. Derivation and interpretation. The figure has 1→2 and 1→3, then 2,3 preceding 4 and 4 preceding 5,6. A topological ordering must place 1 before 2 and 3. D begins 3,2,4,1 and violates both outgoing constraints from 1; A,B,C respect the displayed edges. Thus D.

Original paper, page 2