Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depth First Search #2814

Open
Arjuns-create opened this issue Oct 11, 2024 · 5 comments
Open

Depth First Search #2814

Arjuns-create opened this issue Oct 11, 2024 · 5 comments
Labels
enhancement New feature or request stale Author has not responded to the comments for over 2 weeks

Comments

@Arjuns-create
Copy link

Detailed description

There is a problem on depth first search so i want to create and push my own code

Context

Other users use my code and help them to understand

Possible implementation

#include<bits/stdc++.h>
using namespace std;

vector vis;
vector<vector> g;

void dfs(int node) {
vis[node] = 1;

for(auto v : g[node]) {
    if(!vis[v]) {
        dfs(v);  
    }
}

}

int main() {
int n, m;
cin >> n >> m;

g.resize(n + 1);  
vis.resize(n + 1, 0);  


for(int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);  
}


for(int i = 1; i <= n; i++) {
    if(!vis[i]) {
        dfs(i);
    }
}

return 0;

}

Additional information

No response

@Arjuns-create Arjuns-create added the enhancement New feature or request label Oct 11, 2024
@HAAGIMARU-29
Copy link

HAAGIMARU-29 commented Oct 12, 2024

can you please assign this issue to me ?

@Arjuns-create
Copy link
Author

can you please assign this issue to me ?

okayy

@mihir-k64
Copy link

assign this me to me please under hacktober tag

@Divyansh-jain2
Copy link
Contributor

assign this to me

Copy link
Contributor

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Author has not responded to the comments for over 2 weeks
Projects
None yet
Development

No branches or pull requests

4 participants