Let G V E be a complete directed acyclic graph that has an
Solution
Things to note are:-
1. Graph is complete
2. There exists ordering between every pair of vertices.
3. By asking a query we are establishing some kind of Ordering between two nodes i.e from u to v means u > v and vice versa
So from the point 3 and using the Hint given, we can find Topological sort using Comparison based Sorting
Lets see How ?
Run a sorting algorithm and in the comparison section use query i.e Comparing Two vertices by asking the query we can know whether u>v or v>u . The output will have the Ordering of all the vertices where the first node will be the one whose indegree is 0 and the last node will be the one whose outdegree is 0 , Hence we get the output of Topological Sort
Worst Case lower bound
In comparsion based sort the Worst Case lower bound is (nlogn), hence to find the topological sort the lower bound is nlogn
