Question
Official answer and solution
- Official answer
- C
- From
- Official GATE 2014 answer key
Solution
Find topological sorts of the directed acyclic graph by repeatedly selecting vertices with zero in-degree.
The graph has vertices and directed edges:
- From : ,
- From : ,
- From :
In-degrees of vertices:
- : 0 (no incoming edges)
- : 0 (no incoming edges)
- : 2 (incoming from and )
- : 3 (incoming from , and )
A topological ordering must place every vertex before all vertices it has edges to.
- Either or can be chosen as the first vertex.
- If is chosen first, remaining vertices have in-degrees: . Thus must be second.
After choosing , in-degrees become: . Thus must be third, followed by .
This yields the sequence: . - If is chosen first, remaining vertices have in-degrees: . Thus must be second.
After choosing , is third, followed by .
This yields the sequence: .
Both PSRQ and SPRQ are valid topological orderings, matching option C.
Final answer
C
Common trap
Thinking is a topological sort, but requires to precede , which violates .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 1
- Question
- 23 of 65, printed as CS Q.13
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.