6.8 Cycle detection in Directed Graph |Data Structures and Algorithms Tutorials

Поділитися
Вставка
  • Опубліковано 3 січ 2025

КОМЕНТАРІ • 102

  • @divyanshruhela
    @divyanshruhela 4 роки тому +11

    Your methods are great, I was very confused about cycle detection in directed and undirected graph but you solved my problem. Thanks a lot. Subscribed already

  • @ayaskanta100
    @ayaskanta100 2 роки тому

    brilliant lady this is the best explanation in the entire internet for DFS and cycle detection

  • @aijazsiddiqui1721
    @aijazsiddiqui1721 5 років тому +13

    Thank you, mam, for such a wonderful explanation. I tried to write my own algorithm similar to this, but it has a few flaws. Your algo is excellent.

  • @KevinN44
    @KevinN44 3 роки тому +2

    Thanks for the awesome explanation. I had struggled with understanding this for so long until I found this video 👏🏾👏🏾

    • @alextoppo3958
      @alextoppo3958 Рік тому

      I had struggled to understand what was written on the board

  • @manishmalhotra5883
    @manishmalhotra5883 4 роки тому +1

    I got stuck in one of my leetcode question ...thank you for this super clear explanation mam ... and one more think is that i found solution to this also in gfg but in that i had some doubt .Now its pretty clear .

  • @bawalgroup6355
    @bawalgroup6355 Рік тому +7

    Saviour of ds subjects🥲 jai ho jenny mam ki☺

  • @parasmahajan7741
    @parasmahajan7741 5 років тому +2

    Thanks a lot for covering all the cases I've been looking for.

  • @patrikw1
    @patrikw1 4 роки тому +1

    Thank you Jenny, i finally understand concept

  • @asadaliqureshi3740
    @asadaliqureshi3740 4 роки тому

    Great Job Maam..Stay Blessed...

  • @TheAdityaVerma
    @TheAdityaVerma 5 років тому +11

    i love your eyes

    • @suyashdubey520
      @suyashdubey520 4 роки тому +2

      why bro?? lol

    • @manojnagthane
      @manojnagthane 4 роки тому +1

      Bhai Apne video me Bolte ho Jenny aur Tushar ne Sahi se Nahi padhaya aur Yaha aake nice explaination comment Kar rahe ho... Sahi hai Bhai✌️

    • @priyanshusingh2454
      @priyanshusingh2454 4 роки тому

      Sir aap yha XD

    • @user-mi8ew2to8e
      @user-mi8ew2to8e 4 роки тому

      @@manojnagthane Hypocrisy
      Eyes to waise mast h

    • @kumarashutosh6402
      @kumarashutosh6402 4 роки тому

      are guruji,aap yaha kaise??

  • @kasyapdharanikota8570
    @kasyapdharanikota8570 3 роки тому +1

    very well explained, thank you very much .

  • @_Karma_believer_
    @_Karma_believer_ Рік тому

    I am trying to keep my eyes off but its not closing becz of ur teaching its osm to be u as our teacher ❤️

  • @gauravmaithani4707
    @gauravmaithani4707 2 роки тому

    Thank you mam. This video helped me code it the right way.

  • @sudhirpratapsingh5730
    @sudhirpratapsingh5730 5 років тому +1

    You are doing great,.
    Awesome explanation,
    Thank you

  • @divyanshdixit4944
    @divyanshdixit4944 5 років тому +3

    Ma'am all the videos are very nice and give clarity in the required topics. I request you to please make a proper playlist of all the uploaded videos in the order they should be studied .I feel that in the existing playlist the videos are not in correct order.

  • @Anonymous-2-0-1-2
    @Anonymous-2-0-1-2 5 років тому +1

    thanks . done it right in first attempt .

  • @noorfatima8524
    @noorfatima8524 5 років тому

    ur teaching method is awesome ma’am. 😀😘

  • @lalitkumarmehta6026
    @lalitkumarmehta6026 4 роки тому +3

    the explanation was good, can be made better if code was explained after the explanation of algo

  • @aadityasharma6855
    @aadityasharma6855 3 роки тому

    Thank you so much mam, you have explained very well.

  • @samiulislamdurjoy
    @samiulislamdurjoy 4 роки тому +1

    G 250
    6:30-6:41 main summery of the video is this 11 second(if you find adjacent vertex with flag 0 then its cycled graph.
    10:00 worst case time complexity O(V+E)

  • @tranuctrinh9405
    @tranuctrinh9405 4 роки тому

    thank you, it's really easy to follow

  • @apporvaarya
    @apporvaarya 4 роки тому

    Finally i understood a topic

  • @omchoudhary4931
    @omchoudhary4931 5 років тому +1

    Awsm explainations please continue this amazing work ,💜💜

  • @jayeshborgaonkar9166
    @jayeshborgaonkar9166 5 років тому +2

    you make it look so easy, can you please also discuss the code for the same thanks,

  • @hammadahmed-f1f
    @hammadahmed-f1f 11 днів тому

    ma'am in the beginning at vertice B i decide to go for D instead of C then what will happen to C?
    will it remain unvisited as the cycle already got detected or is there any further step?

  • @jewellist1
    @jewellist1 5 років тому +3

    In your algorith, you started from A and traverse along with it's adjacent with the help of stack. what would happen if you start with c? it doesn't have any adjacent so you popped it from stack, now what you will do?

    • @MotoRider23605
      @MotoRider23605 4 роки тому

      Md Hossain we can then use a for loop ,for n vertices,and start all over taking each vertices as my starting node...I hope so this will work

    • @muruganm7632
      @muruganm7632 4 роки тому

      The ideal protocol would be start with a node which has the in-degree 0. This will work always. Hope this helps.

  • @kunalpilley3317
    @kunalpilley3317 3 роки тому +1

    Hi ma’am you are a wonderful teacher.
    There seems a problem in the approach as cycle detection in graph is different from tree . Coz in a graph a vertex can have multiple parents.
    in the same example , If you take only vertex A B And C . There is no cycle . But your method will indicate it as a cycle.

    • @joschistep3442
      @joschistep3442 Рік тому

      No, it won't. When the algo comes to C, before it can move back to A and then find the other way to C, the flag of C will be set to 1. The algo only indicates a cycle if the flag of a successor is 0. This can only happen if there is a cycle, because the flag of any vertex is set to 0 only while the algo is looking at the successors of this very same vertex. Therefore if you come to a vertex with flag 0, this means that this vertex is its own successor.

  • @stalera
    @stalera 5 років тому +6

    I'm still unclear with the need of parent map. Using stack itself we can identify the cyclic path. Please correct me if I'm wrong.

    • @a_l_o_k_1991
      @a_l_o_k_1991 5 років тому

      Parent map is required to find the node which is responsible for creating cycle.

    • @stalera
      @stalera 5 років тому +1

      Why wouldn't the stack be sufficient for that?

    • @a_l_o_k_1991
      @a_l_o_k_1991 5 років тому +5

      @@stalera Seems like you are correct.. if we pop the element from stack till B we will get the cycle.

  • @DrakeHDxgaming
    @DrakeHDxgaming 10 місяців тому

    great vid as always ,what would the space complexity be ? is it O(v + e) aswell ?

  • @User-ug9jz
    @User-ug9jz 3 роки тому

    I made one without using flag. the idea is to jot down the vertices when we traverse to a node that has an edge directed to the root

  • @sahilkaushik6856
    @sahilkaushik6856 5 років тому +4

    will you please provide the code of algo used in lecture

  • @nikhileshchinnu4336
    @nikhileshchinnu4336 3 роки тому

    my mom said to follow my dreams so i subscried you and i follow you

  • @amanagrawal8715
    @amanagrawal8715 5 років тому +1

    if there is an edge from e->c will that be considered a cycle? and also in geeksforgeeks they haven't provided the source how to find out the source in order to compute the cycle

  • @류호성-v6h
    @류호성-v6h Рік тому

    if its visited, but popped out of the stack, is it a cross edge?????

  • @mostafaelmenbawy5473
    @mostafaelmenbawy5473 3 роки тому

    Where can I check a code implementation of this algorithm, please?

  • @jimenluhar7126
    @jimenluhar7126 4 роки тому

    Beauty with brain !! 🌹

  • @lalitkumarmehta6026
    @lalitkumarmehta6026 4 роки тому +2

    Practice code- leetcode.com/problems/course-schedule/
    leetcode.com/problems/course-schedule/discuss/663857/C%2B%2B-or-DFS-Solution-with-explanation

  • @aaryaparikh6447
    @aaryaparikh6447 3 роки тому

    Hello Ma'am, I have a question how can a graph be traversed if the source node selected is the end node. In short i want to know how to select the appropriate node for traversing

  • @Gerald-iz7mv
    @Gerald-iz7mv 2 роки тому

    hi great vid - can you use the same algo for directed and undirected graph?

  • @pusarlaaishwarya5035
    @pusarlaaishwarya5035 4 роки тому

    Mam can you please make a video on printing have unique paths in a graph and that not involved in forming a cycle in a graph

  • @sindhujaparnam6641
    @sindhujaparnam6641 4 роки тому

    Hi nice video but I don’t think it works in all the cases since ur checking if we are trying to push an element which is already in stack ,but consider the following adjacency list (0 1,7) (5 0) (7 1) here 1 will be in stack when coming from 0 and we will try to push again 1 into the stack while coming from 7 but there is no cycle present so just checking duplicates in the stack doesn’t detect cycle. Correct me if I am wrong

    • @rohitk2629
      @rohitk2629 4 роки тому +1

      u r wrong. flag= 1 while moving from 7 to 1. and flag=-1 while moving from 0 to 1.

  • @prasannathapa1024
    @prasannathapa1024 4 роки тому +3

    Please can someone write a Pseudocode or C/C++ or python or java code for this

  • @christiandave100
    @christiandave100 4 роки тому

    How about disconnected graph??

  • @darshansolanki5535
    @darshansolanki5535 4 роки тому

    I think ma'am, with this approach we cannot detect cycle if we don't give out Proper source node like for e.g tried with source as 2 as we don't know the parent at the start so say -1

    • @darshansolanki5535
      @darshansolanki5535 4 роки тому

      For that, we want to start with any node, without having the knowledge of parent we need to count the indegree for each vertex and then select the node having indegree as zero

  • @ankitparashar8730
    @ankitparashar8730 4 роки тому +1

    I love u mam💖💖💖💖🥰🥰🥰🥰🥰🥰🥰

  • @ganeshpawar698
    @ganeshpawar698 3 роки тому

    Mam count the 6 cycle ? Please the solution.

  • @aadillakdawala1577
    @aadillakdawala1577 7 місяців тому

    but a,b,c are also cyclic why did we not consider it?

    • @musicpanda8333
      @musicpanda8333 Місяць тому

      @@aadillakdawala1577 did you find out

    • @puspalatakar7006
      @puspalatakar7006 17 днів тому

      Abc is not a cycle since the edge is from a->c

  • @sunnysinha9728
    @sunnysinha9728 4 роки тому

    Mam aap codechef ka editorials daaliye..
    long challenge ya short challenges ka

  • @shivrajsingh-qv3tl
    @shivrajsingh-qv3tl 4 роки тому

    Ma'am ABC also form cycle

    • @deepakkumar-kk4hn
      @deepakkumar-kk4hn 4 роки тому +2

      ABC does not form a cycle, you can go from A to B and then B to C but can not go C to A(since arrow point from A to C) so ABC does not form a cycle.

  • @dr4ks
    @dr4ks 2 роки тому

    Hello,is it possible to share the code of this solution with us. If it is,please share.

  • @adilandagi1207
    @adilandagi1207 2 роки тому

    Code is missing in your explanation

  • @deepakkumar-kk4hn
    @deepakkumar-kk4hn 4 роки тому

    Can't we use BFS to detect cycle in directed graph?
    I followed the BFS approach for this example in the video but not getting the expected result.

  • @bharatgupta1188
    @bharatgupta1188 4 роки тому +1

    mam thodi loud banaya kro vedio plzzzzzzzzz

  • @sahilsaxena8374
    @sahilsaxena8374 4 роки тому

    Can you please provide us the code

  • @someshmaurya1515
    @someshmaurya1515 4 роки тому

    Order of video 6.8 and 6.9 is wrong, reverse it

  • @satashreeroy1652
    @satashreeroy1652 4 роки тому

    If you remove BE, there is still a cycle BACB.

  • @creative35711
    @creative35711 4 роки тому

    Is Programming possible for you to teach Madam. Only Concepts I see.

    • @viralvideoa
      @viralvideoa 4 роки тому

      Konsi class me pdhta he tu

  • @SandeepPrajapati-he3fk
    @SandeepPrajapati-he3fk 4 роки тому

    Ma'am board pr concentration hi nhi ho paa rha aapko dekh kr... 😍

  • @sucmanh
    @sucmanh Рік тому

    You are so pretty!

  • @shredder_plays
    @shredder_plays 5 років тому +1

    atleast try to maintain the quality of video minimum 720p

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  5 років тому +2

      Thanks for suggestions... Will do that form now onwards

  • @Rahul.r.r_p
    @Rahul.r.r_p 11 місяців тому

    Day 66

  • @sarthak8643
    @sarthak8643 3 роки тому

    please don't put soo many ads in the video they are annoying

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  3 роки тому

      🤨will take care in later videos..

    • @sarthak8643
      @sarthak8643 3 роки тому

      @@JennyslecturesCSIT thank you ma'am I cleared my exams bcoz of your lectures 🥺😭

  • @dharmendramaurya22
    @dharmendramaurya22 5 років тому

    one of the annoying things in your vide is the long green text at the bottom (like subscribe.......). its too long

  • @jazzochannel
    @jazzochannel 5 років тому +8

    I wish you were my girlfriend :) what about the complexity of finding all cycles? same?

  • @muhammadshahidqayyum7167
    @muhammadshahidqayyum7167 4 роки тому

    Bolti Aankhain

  • @davidd8875
    @davidd8875 4 роки тому

    a very beautiful woman