Segmentation fault in dfs

Revision en1, by indresh149, 2022-04-23 23:06:24

void dfs(int node, vector &vis, vector adj[], vector &storeDfs) { storeDfs.push_back(node); vis[node] = 1; for(auto it : adj[node]) { if(!vis[it]) { dfs(it, vis, adj, storeDfs); } } }

public: // Function to return a list containing the DFS traversal of the graph. vector dfsOfGraph(int V, vector adj[]) { // Code here vector storeDfs; vector vis(V+1, 0); for(int i = 1;i<=V;i++) { if(!vis[i]) dfs(i, vis, adj, storeDfs); } return storeDfs; } };

What is the error giving segmentation fault?

Tags dfs

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English indresh149 2022-04-23 23:06:24 715 Initial revision (published)