GATE / CS ARCHIVE

GATE CSE 2014 SET 1 / QUESTION 13

GATE CSE 2014 Set 1 Q13

Algorithms · Graph Algorithms · Full GATE CSE 2014 Set 1 paper

GATE 2014 Set 1, Q13 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