Detect cycle in graph | Hello world Graph Playlist Easy | DFS Algorithms | Hindi Explained

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 69

  • @uditsethi2578
    @uditsethi2578 3 ปีที่แล้ว +19

    Today I completed this playlist that i started 2 days back and I can't believe that seems to me very hard earlier is now feels to me like a normal hello world program and after I completed your BFS video starting from 1 video of playlist, after BFS i done all the question by myself without playing your video first ....Thanks alot May god bless you and wish this channel will be counted under the best education channels especially for CS engineers in upcoming 3 years.

    • @HelloWorldbyprince
      @HelloWorldbyprince  3 ปีที่แล้ว +1

      Thanks udit bhai ...such a great motivation for me

  • @ankitaaaaaaa25
    @ankitaaaaaaa25 7 หลายเดือนก่อน

    Thank you so much, I was really scared to solve graph problems earlier, but now I am able to understand it and also solve them by myself.

  • @tusharnain6652
    @tusharnain6652 2 ปีที่แล้ว +2

    The Best Graph Series, ❣️

  • @ayushhh2257
    @ayushhh2257 3 ปีที่แล้ว +3

    Bhiya aap bhot shi tareeke se samjhate ho👍👍

  • @shivanshsharma399
    @shivanshsharma399 2 ปีที่แล้ว +3

    you are making really great videos bro 👏👏

  • @oqant0424
    @oqant0424 2 ปีที่แล้ว

    yes bhaiya maine ek ek function ko chaala chala ke dekha....literally clear ho gaya sab

    • @HelloWorldbyprince
      @HelloWorldbyprince  2 ปีที่แล้ว +1

      waoo yaar aap sach me bhut hard working ho

    • @oqant0424
      @oqant0424 2 ปีที่แล้ว

      @@HelloWorldbyprince thank u so much bhaiya

  • @rode_atharva
    @rode_atharva 8 หลายเดือนก่อน

    bhai sach me easy bana diya yaar tumne

  • @gokulnaathb2627
    @gokulnaathb2627 10 หลายเดือนก่อน

    Thank you bhaiya, nice explanation

  • @Thescienceworld652
    @Thescienceworld652 2 ปีที่แล้ว +1

    balle balle ho gya 😁😁

  • @oqant0424
    @oqant0424 2 ปีที่แล้ว +1

    at #4:09 i had also the same thought process.....i analysed on my own why it will be wrong....but i couldn't come up with solution

  • @goyaldeekshant
    @goyaldeekshant 2 ปีที่แล้ว +1

    not able to do that course schedule leetcode problem:

  • @akshittomar2401
    @akshittomar2401 2 ปีที่แล้ว +4

    Brother Question of LeetCode #207 Course Schedule , belongs to the concept of detecting a cycle in Directed Graph we can't do it using Non-Directed Graph .

    • @LOVE-kf9xi
      @LOVE-kf9xi ปีที่แล้ว

      wahi toh , mai chutiya zabardasti dekh rha hu galti kaha hai .

  • @jayeshtak2530
    @jayeshtak2530 10 หลายเดือนก่อน

    Doesn't work on Leetcode 207 ?

  • @compc_59_manishyadav77
    @compc_59_manishyadav77 2 ปีที่แล้ว +2

    I want to know where is parent updating , like initially we have assigned -1 as parent , so are we upadating it some where , nahi to it will keep parents as -1, if I am wrong please do correct me @ anyone!!!

    • @HelloWorldbyprince
      @HelloWorldbyprince  2 ปีที่แล้ว +2

      yes u r on the right way of learning bus please ek baar code ko dry run karke dekho sach me mazaa aa jayega kissi v ek example ko aache se copy pen me write down kijiye

  • @ankitkumarsingh8346
    @ankitkumarsingh8346 2 ปีที่แล้ว

    Brilliant explanation

  • @palashmalu6278
    @palashmalu6278 ปีที่แล้ว

    sir aap best ho !!
    also cp wala course enough hai ti get stated ??

  • @ShubhamKumar-ex3nk
    @ShubhamKumar-ex3nk 2 ปีที่แล้ว

    what if there is a self loop?

  • @easylearning6647
    @easylearning6647 ปีที่แล้ว

    thank you for your efforts

  • @krushnapatil9196
    @krushnapatil9196 3 ปีที่แล้ว

    parent banane ka code konse line mein hai

  • @amanpandey4550
    @amanpandey4550 2 ปีที่แล้ว +4

    Cpp Code -
    bool DFS(vector adj[], vector&vis, int source, int parent){
    vis[source]=true;
    for(int x : adj[source]){
    if(vis[x]==false){
    if(DFS(adj,vis,x,source))
    return true;
    }
    else if(x!=parent)
    return true;
    }
    return false;
    }
    bool isCycle(int v, vector adj[]) {
    // Code here
    vector vis(v+1,false);
    for(int i=0; i

  • @pranavkorhale5089
    @pranavkorhale5089 2 ปีที่แล้ว +1

    //my logic instead of tracking parent I use hashset to save the visited edge
    //if vertex is already visited but edge to that vertex not in hashiset then graph contains cycle
    //for more idea JAVA Code
    class Solution {
    // Function to detect cycle in an undirected graph.
    public boolean ans = false;
    public boolean isCycle(int V, ArrayList adj) {
    ans = false;
    HashSet hs = new HashSet();
    boolean []visited = new boolean[V];
    for(int i=0;i

  • @prabhatmishra5667
    @prabhatmishra5667 2 ปีที่แล้ว +6

    Complete code -
    bool h(vector adj[],vector &v,int s,int p)
    {
    v[s] = true;
    for(auto x:adj[s])
    {
    if(!v[x])
    {if(h(adj,v,x,s))
    return true;}
    else if( x!=p )
    return true;
    }
    return false;
    }
    bool isCycle(int V, vector adj[])
    {
    vector v(V,false);
    for(int i = 0; i < V; i++)
    { bool ans=false;
    if(!v[i])
    ans=h(adj,v,i,-1);
    if(ans)
    return true;
    }
    return false;
    }

  • @VaibhavSutar-xm3cn
    @VaibhavSutar-xm3cn 8 หลายเดือนก่อน

    class Solution {
    // Function to detect cycle in an undirected graph.
    dfs(current,parent,visited,adj,map){
    if(visited[current] && map[parent] !== current) return 1
    visited[current] =true
    let adjacent = adj[current]
    if(adjacent){
    for(let i=0;i

  • @adityanjr
    @adityanjr 2 ปีที่แล้ว

    course schedule uses concept of cycle detection in Directed Graph...

  • @gauravkumar6632
    @gauravkumar6632 2 ปีที่แล้ว

    bhai how parent is increasing?
    you initialized parent=-1;

    • @Coder_DhruvArora
      @Coder_DhruvArora 2 ปีที่แล้ว +2

      In recursive function calls, we are passing different parent for each call

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq 3 ปีที่แล้ว +2

    👌weighted graph ke kuch karva do

  • @yourshawonn
    @yourshawonn ปีที่แล้ว

    Sir please upload krushkal algorithm class

  • @SunnyGupta00
    @SunnyGupta00 2 ปีที่แล้ว +1

    Bs bhai dsu pe video bana do

  • @rahulgautam6387
    @rahulgautam6387 2 ปีที่แล้ว +1

    Bhaiya isme jo question h uska solution nhi 41 test cases pass hue out of 51 and finally solution solve nhi ho pa rha h🥲

  • @oqant0424
    @oqant0424 2 ปีที่แล้ว

    11/32 done (5.11.22)

  • @VishalKumar-ce9pe
    @VishalKumar-ce9pe 2 ปีที่แล้ว +2

    -----------------------------------------------------------CODE-----------------------------------------------------
    class Solution {
    public:
    bool DFS(vector adj[], int u, vector& visited, int parent)
    {
    visited[u] = true;
    for(auto a: adj[u])
    {
    if(visited[a] == false)
    {
    if(DFS(adj, a, visited, u))
    return true;
    }
    else if(a!=parent)
    {
    return true;
    }
    }
    return false;
    }
    bool isCycle(int V, vector adj[]) {
    vector visited(V+1, false);
    for(int i = 0; i

  • @knowsbetter4113
    @knowsbetter4113 ปีที่แล้ว

  • @yashijain7447
    @yashijain7447 2 ปีที่แล้ว

    Playlist for Tree and DP plzz

  • @SurajKumar-cj7md
    @SurajKumar-cj7md ปีที่แล้ว

    C++ CODE
    // Function to detect cycle in an undirected graph.
    bool DFSREC(int s, vector adj[],vector&visited,int parent)
    {
    visited[s]=true;
    for(int u:adj[s])
    {
    if(visited[u]==false)
    {
    if(DFSREC(u,adj,visited,s))
    return true;
    }
    else if(u!=parent)
    {
    return true;
    }
    }
    return false;
    }
    bool isCycle(int V, vector adj[])
    {
    vectorvisited(V+1,false);
    for(int i=0;i

  • @cr7johnChan
    @cr7johnChan 2 ปีที่แล้ว

    #include
    #include
    #define V 4
    using namespace std;
    void edge(vectorgraph[],int i ,int j){
    graph[i].push_back(j);
    graph[j].push_back(i);
    }
    int check(vectorgraph[],vector&visited,int j,int prev){
    visited[j]=1;
    for(int i=0;i

  • @VaibhavSutar-xm3cn
    @VaibhavSutar-xm3cn 8 หลายเดือนก่อน

    at 5.55 krte he hum solve bhai
    wait

  • @lokendrayadav91
    @lokendrayadav91 2 ปีที่แล้ว

    bhai pura playlist taabadtod hai ,

    • @HelloWorldbyprince
      @HelloWorldbyprince  2 ปีที่แล้ว

      Thanks bro for the support Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀

  • @gokulnaathbaskar9808
    @gokulnaathbaskar9808 2 ปีที่แล้ว

    • @HelloWorldbyprince
      @HelloWorldbyprince  2 ปีที่แล้ว

      Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀