DFS search time complexity analysis

Viewed 27

In finding the cycle in the dfs if we pass & to the boolean vector the code correctely submitted but when I I don't use it give time complexity erroe

bool dfs(vector<int>adj[],int V,vector<bool>&b,int i,vector<bool>&d){
   
    b[i]=true;
    d[i]=true;
    vector<int>::iterator it;
   
    for(it=adj[i].begin();it!=adj[i].end();++it){
        if(b[*it]!=true){
          
           if(dfs(adj,V,b,*it,d)){
               return true;
           }
        }
        else if(d[*it]==true){
            return true;
        }
        
    }
    d[i]=false;
   return false;
}
0 Answers
Related