Graphs
May 29, 2020
DSA
DFS
void dfs-bfs(int s, int n, vector adj[])
{
stack st;
// replace with queue for bfs
bool vis[n] ={0};
st.push(s);
cout<<"DFS: ";
while(!st.empth())
{
int node = st.top();
vis[node]=1;
cout<< node<<" ";
for(auto i: adj[node])
{
st.push(i);
}
}
}