retagged by
11,922 views
43 43 votes

Consider the directed graph below given. 

Which one of the following is TRUE?

  1. The graph does not have any topological ordering.
  2. Both PQRS and SRQP are topological orderings.
  3. Both PSRQ and SPRQ are topological orderings.
  4. PSRQ is the only topological ordering.

5 Answers

Best answer
43 43 votes

C. Both PSRQ and SPRQ are topological orderings

  1. Apply DFS by choosing P or S as starting vertices
  2. As the vertex gets a finishing time assign it to the head of a linked list
  3. The linked list is your required topological ordering
edited by
40 40 votes

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

edited by
8 8 votes
The graph doesn't contain any cycle, so there exist topological ordering. P and S must appear before R and Q because there are edges from P to R and Q, and from S to R and Q.

answer is c
0 0 votes

 


There are no cycles in the graph, so topological orderings do exist.
We can consider P & S as starting vertex, followed by R & Q.
Hence, PSRQ & SPRQ are the topological orderings.

0 0 votes
Think of edges as courses. If an edge is there between two courses as C1->C2, then C1 is prerequisite for C2.
Answer:
Position:
Show:

Related questions

78 78 votes
11 answers 11 answers
33.2k
33.2k views
go_editor asked Sep 28, 2014
33,192 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
30 30 votes
7 answers 7 answers
13.0k
13.0k views
pC asked Dec 21, 2015
12,959 views
Consider the DAG with $V = \{1,2,3,4,5,6\}$ shown below.Which of the following is not a topological ordering?$1$ $2$ $3$ $4$ $5$ $6$$1$ $3$ $2$ $4$ $5$ $6$$1$ $3$ $2$ $4$...
51 51 votes
5 answers 5 answers
19.3k
19.3k views
go_editor asked Sep 26, 2014
19,319 views
Let $G$ be a graph with $n$ vertices and $m$ edges. What is the tightest upper bound on the running time of Depth First Search on $G$, when $G$ is represented as an adjac...
61 61 votes
9 answers 9 answers
29.2k
29.2k views
go_editor asked Sep 26, 2014
29,162 views
Let $P$ be quicksort program to sort numbers in ascending order using the first element as the pivot. Let $t_1$ and $t_2$ be the number of comparisons made by P for the i...