Topological Sorting_2
#include<bits/stdc++.h> using namespace std; long long visited[100]; vector <int> grp[200]; map<int,int>vis; stack<int>st; int n; int topologicalSortUtill(int v) { vis[v] = 1; int l=grp[v].size(); int u; for(int i=0;i<l;i++) { u=grp[v][i]; if (!vis[u]) topologicalSortUtill(u); } st.push(v); } int topologicalSort() { for(int i=0;i<n;i++) vis[i]=0; for(int i=0;i<n;i++) if(vis[i]==0) topologicalSortUtill(i); while(st.empty()==0) { cout<<st.top()<<" "; ...