Consider the directed graph below given.
Which one of the following is TRUE?
The C option has been copied wrongly
C. Both PSRQ and SPRQ are topological orderings
I think, here it (http://www.geeksforgeeks.org/all-topological-sorts-of-a-directed-acyclic-graph/) should be used for getting all possible answer.
In general for getting one possible answer, approach (DFS method ) proposed by you looks good.
choose vertex in the graph which has 0 indegree . now see graph has such two vertices ie P,S so we can start topological sort either from vertex P or from S .
lets first start from vertex P now remove this vertex from graph ,we left with three vertices named asQ,S,R from these vertices see which vertex has INDEGREE 0,S vertex HAS indegree 0 therefore sequence is P,S,R,Q
repeat the above step from vertex S we get sequence as S,P,R,Q