Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u → v, vertex u comes before…
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u → v, vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG. Now write a C/C++ Program with the following input and Output.
Input: 5 2, 5 0, 4 0, 4 1, 2 3, 3 1
Output: 5 4 2 3 1 0
From the Combined Bank Assistant Programmer (CSE) March 2021 – Preliminary exam, question 79 of 86.
More from this paper
- Previous: Write a C/C++ program to check Balanced parentheses in an Expression.
- Next: We are given an array of integers and a range, we need to find whether the subarray which falls in this range has values in the form of a…
- All questions in Combined Bank Assistant Programmer (CSE) March 2021 – Preliminary