• edited by
744 views
0 0 votes

Focus on the word constraint , I am little confused (in meaning of the word)here. What should be  the answer  2 or 16.

We are interested in topological orderings of the following DAG that satisfy one or both of the following constraints:
1. 4 appears before 3
2. 8 appears after 7

How many such orderings are there?
16
Correct Option

Solution :
16
Topological sort is of the form 1 , followed by a topological ordering of $\{2,3,4,5\}$, followed by 6 , followed by a topological ordering $\{7,8,9\}$. Nodes $\{2,3,4,5\}$ have ( 4 choose 2 ) $=6$ topological orderings of which only one, 2-3-4-5 has 3 before 4 . All other orderings have 4 before 3: 2-4-3-5, 2-4-5-3, 4-2-3-5, 4-2-5-3, 4-5-2-3.
Nodes $\{7,8,9\}$ have 3 topological orderings, $7-8-9,8-7-9,8-9-7$, of which two have 8 before 7 and one has 8 after 7. There are $6 \times 3=18$ total topological orderings of which $1 \times 2=2$ violates both conditions, so 16 satisfy one condition or both.

1 Answer

0 0 votes
There are total of 18 topological orderings possible.

Out of which only 2 does not satisfy both the constraints .

1$\rightarrow$ 2$\rightarrow$4$\rightarrow$5$\rightarrow$6$\rightarrow$8$\rightarrow$7$\rightarrow$9$\rightarrow$10

1->2->4->5->6->8->9->7->10

If the question is which follows both 1 and 2,then answer is $5$.

If the question is only about either 1 or 2 ,then also answer is $16$
Position:
Show:

Related questions

1 1 vote
1 1 answer
766
766 views
Overflow04 asked Oct 20, 2022
766 views
How option B is incorrect.Q. 33Have any Doubt?Suppose we run the Bellman-Ford algorithm on a weighted graph with $n$ vertices and observe that some distances decrease in...
5 5 votes
1 1 answer
4.8k
4.8k views
manvi_agarwal asked Sep 15, 2018
4,752 views
Also let me know the approach to find back edges, cross edges, forward edges,How to solve these questions(a) 2(b) 4(c) 6(d) None of theseQ. 3 Consider the following graph...
1 1 vote
1 1 answer
1.8k
1.8k views
Shubham Kumar Gupta asked Dec 3, 2017
1,800 views
DFS Graph Traversal:Starting vertex $=\mathrm{V}_{6}$Identify valid DFS.$6,8,7,5,4,2,1$$6,3,1,2,4,5,8,7$$6,3,7,8,5,2,4,1$$6,8,5,4,2,1,7$
0 0 votes
1 1 answer
2.4k
2.4k views
VS asked Nov 26, 2017
2,400 views
Consider the following graph G.The BFS traversal on G is modified as : The starting vertex for traversal will be 'a'. At any level (breadth), vertices are visited in alph...