Consider the directed graph below given. Which one of the following is TRUE?

2014

Consider the directed graph below given. 

Which one of the following is TRUE?

  1. A.

    The graph does not have any topological ordering.

  2. B.

    Both PQRS and SRQP are topological orderings.

  3. C.

    Both PSRQ and SPRQ are topological orderings.

  4. D.

    PSRQ is the only topological ordering.

Attempted by 146 students.

Show answer & explanation

Correct answer: C

Key constraints: From the graph the directed edges are P→Q, P→R, S→R, S→Q and R→Q. So P and S must come before R and Q, and R must come before Q.

  • P must appear before R and Q.

  • S must appear before R and Q.

  • R must appear before Q.

  • There is no edge between P and S, so their relative order can be either P then S or S then P.

Conclusion: The only sequences that satisfy all of these constraints place P and S first (in either order), then R, then Q. Therefore the valid topological orderings are

  1. P S R Q

  2. S P R Q

Thus the statement that both PSRQ and SPRQ are topological orderings is correct; the other given statements are false.

Explore the full course: Gate Guidance By Sanchit Sir