Depth First Traversal for a Graph | GeeksforGeeks

Sdílet
Vložit
  • čas přidán 7. 11. 2016
  • Explanation for the article: www.geeksforgeeks.org/depth-fi...
    Read More : www.geeksforgeeks.org/depth-f...
    This video is contributed by Illuminati.

Komentáře • 102

  • @amitpadaliya6916
    @amitpadaliya6916 Před 7 lety +162

    at 1.25 speed it looks good

  • @sissoko11
    @sissoko11 Před 6 lety +74

    "This video is contributed by Illuminati." woh... what?

  • @abdolabdollah1783
    @abdolabdollah1783 Před 3 lety

    Excellent Job, Thanks for your service

  • @piriyaie
    @piriyaie Před 4 lety

    This video helped me a lot. Thank you.

  • @ammarimran5172
    @ammarimran5172 Před 4 lety +6

    You gave us the idea using stack, but implementing recursively on website/example.

    • @bharathram3977
      @bharathram3977 Před 4 lety +10

      Recursive implementation uses the implicit stack (in memory). So, it's kinda stack-based implementation.

  • @aussieraver7182
    @aussieraver7182 Před 5 lety

    how do you mark as visited on template values?

  • @jushas9276
    @jushas9276 Před 5 lety +31

    after visiting E why we are not visiting C (alphabetically).I think we have to visit C first and then F

  • @kiranmallikarjun8618
    @kiranmallikarjun8618 Před 5 lety

    why we use only stack in dfs but not queue

  • @bashierdahman4550
    @bashierdahman4550 Před 4 lety +5

    excellent videos! I thoroughly understand graphs now

  • @rohitbisht4036
    @rohitbisht4036 Před 6 lety +1

    Plz write n explain psuedo or algorithm.

  • @nguy0310
    @nguy0310 Před 4 lety +3

    This video works for me. I understand the concept now. Thanks!

    • @ShiShiva439
      @ShiShiva439 Před 3 lety +1

      Wow are you the Tam from Big bang theory? Sheldon's childhood bestfriend? :O Sheldon could have taught you this and whole computer science if you had asked him.

    • @nguy0310
      @nguy0310 Před 3 lety

      @@ShiShiva439 I’m a big fan of the show, not as smart as that Tam but cuter :)

    • @EllieOK
      @EllieOK Před 3 lety

      @@ShiShiva439 hahahahaahhaahahah

  • @nitishaagrawal7116
    @nitishaagrawal7116 Před 4 lety

    Please ,make a video lecture for GetPath_DFS problem.

  • @karanh
    @karanh Před 4 lety +6

    Suppose we go in the order of A B and then E, what condition would make it go to F but not C? Would the order A B E C F D also be a depth-first traversal?

    • @swtnk7468
      @swtnk7468 Před 4 lety +2

      yea,,,its not clear,,,,why do we even go E from D,,,,we were going left first,,,suddenly we go e but not F

    • @gsb22
      @gsb22 Před 3 lety +2

      It depends on the graph internal implementation and how you have added edges. Suppose for node E, you add an edge, EF in the graph before EC. So what happens is, the array storing edges for E would be E --> [F, C]. So when your DFS hit node E, it will look for its first child that is F and here you go other way. Basically, if you have used same graph class, the only way your DFS would come out different if the you have added edges in different order.

  • @teetanrobotics5363
    @teetanrobotics5363 Před 4 lety

    Please order the playlist properly

  • @Colors_Of_My_Soul
    @Colors_Of_My_Soul Před 6 lety +3

    How we can visit E after D if we are following depth first? Isn't it making this a breadth first approach ?

  • @galaxyamansingh
    @galaxyamansingh Před 7 lety +21

    Why you visit F from E instead of C as C comes first in alphabetical order?

    • @dyankristoper
      @dyankristoper Před 7 lety +9

      I agree with you. I thought the order was A,B,D,E,C,F

    • @powerpointdesigner7389
      @powerpointdesigner7389 Před 7 lety +4

      Same here

    • @nands4410
      @nands4410 Před 6 lety +6

      Doesnt matter you can do it anyway..it has nothing to do with alphabetical order.

    • @sumeetnegi9926
      @sumeetnegi9926 Před 6 lety +4

      Can i visit node f from d instead of e? if yes then my answer would be ABDFEC. Will it also be correct?

    • @mamtanegi3198
      @mamtanegi3198 Před 3 lety +1

      @@sumeetnegi9926 yes

  • @rajthakrar2291
    @rajthakrar2291 Před 3 lety

    Is this traversal unique?.. I mean does it give a unique traversal?

  • @rajibroychoudhury4116
    @rajibroychoudhury4116 Před 6 lety +2

    why u choose node F after node E? why not node C?

  • @dawitkeba2783
    @dawitkeba2783 Před 7 lety +13

    c must pushed to stack and visited before f since c is comes before f alphabetically

  • @AyushGupta-kp9xf
    @AyushGupta-kp9xf Před 4 lety +2

    thanks illuminati for the contribution

  • @bushrazafar6147
    @bushrazafar6147 Před rokem +1

    Best video I have ever seen ,in no time all my concepts are clear ❤

  • @chandrikashrestha
    @chandrikashrestha Před 4 lety +1

    i want to ask why did u visit E after D, why not F?? I'm confused about it

    • @saikatbiswas3549
      @saikatbiswas3549 Před 4 lety +1

      because E and D are the two adjacent vertices of B. Here F is adjacent to D or E . So first you have to visit E or D. Order is not important like B --> D or B --> E both are correct.

  • @sumeetnegi9926
    @sumeetnegi9926 Před 6 lety

    Can i visit node f from d instead of e? if yes then my answer would be ABDFEC. Will it also be correct?

    • @shivaay448
      @shivaay448 Před 6 lety +1

      Sumeet Negi yes bro it is also correct

    • @prasanna5836
      @prasanna5836 Před 5 lety

      @@shivaay448 you sure mate?

  • @RiyaKumari-yf7nt
    @RiyaKumari-yf7nt Před 4 lety +1

    That means, output of many students can be differ with each other ?

    • @gsb22
      @gsb22 Před 3 lety

      For the same graph it should not be. If you put edges in different order then it may differ.

  • @akashshukla3163
    @akashshukla3163 Před 3 lety

    i could not find stack in gfg code

  • @Akashsingh-us2lp
    @Akashsingh-us2lp Před 6 lety +1

    Are two or more answer possible in DFS??

    • @ashishk8490
      @ashishk8490 Před 5 lety

      Yes. It may differ in directed and undirected graph

    • @aronquemarr7434
      @aronquemarr7434 Před 4 lety

      Yes, if you're doing it manually.

  • @tapanjeetroy8266
    @tapanjeetroy8266 Před 6 lety

    thank you sir...

  • @adameid7368
    @adameid7368 Před 7 lety +7

    Thanks for notes but you didn't clarify the most important thing which is the code

    • @IStMl
      @IStMl Před 4 lety +1

      If u get the algo u get the code

  • @arfatbagwan48
    @arfatbagwan48 Před rokem

    Sir please explain us code

  • @inderjeetagarwal202
    @inderjeetagarwal202 Před 6 lety +5

    After reaching E why we haven't take C but took F

    • @tekeshpal209
      @tekeshpal209 Před 6 lety

      Inderjeet Agarwal bcz we have to choose depth first

    • @bbx5617
      @bbx5617 Před 4 lety

      You can choose whichever you want, they both fit in the criteria

  • @annawilson3824
    @annawilson3824 Před 2 lety

    But the stack is not used here, it is a recursive approach.

  • @bishwendrachoudhary2281
    @bishwendrachoudhary2281 Před 7 lety +2

    plz explain code also

  • @swajangolder5254
    @swajangolder5254 Před 4 lety +2

    Where is the use of stack here?????

    • @saikatbiswas3549
      @saikatbiswas3549 Před 4 lety

      here stack is using for back-tracking. I think in this video the program is written in c++. Use java for implementing a Stack data structure. watch this czcams.com/users/redirect?q=http%3A%2F%2Fwww.geeksforgeeks.org%2Fdepth-first-traversal-for-a-graph%2F&v=Y40bRyPQQr0&event=video_description&redir_token=z8iambMT2HOvNRQN0rrqubjpCx18MTU4ODkyNTc1N0AxNTg4ODM5MzU3

    • @lokeshjawale1562
      @lokeshjawale1562 Před 3 lety

      The stack is used internally
      While doing recursion....

  • @uzmaruksarshaikh1242
    @uzmaruksarshaikh1242 Před 5 lety

    Thank u

  • @jaspreetkaur-uo9fv
    @jaspreetkaur-uo9fv Před 4 lety

    I want dfs and bfs with graphics

  • @AmirAli-gv7kn
    @AmirAli-gv7kn Před 6 lety +6

    the order should be ABDECF if u follow alphabetically

    • @xy8014
      @xy8014 Před 6 lety

      CodePatchers yes... Is it wrong here??

  • @abmallick
    @abmallick Před 5 lety +2

    *watch at 3x*

    • @prasannakumar7035
      @prasannakumar7035 Před 5 lety +1

      Maximum of 2x is there !! how to watch videos at 3x speed ????

    • @IStMl
      @IStMl Před 4 lety

      @@prasannakumar7035 Chrome extension

    • @IStMl
      @IStMl Před 4 lety

      @@prasannakumar7035 Chromium extension

  • @ankushchhabra6092
    @ankushchhabra6092 Před 4 lety

    u just explain only the algorithm......but what about code.....F

    • @hansenhe7993
      @hansenhe7993 Před 4 lety +1

      Once you understand the algorithm, then the code would be easy to write. If you can't write it, then it means you haven't fully understood the algorithm.

  • @ashrafulfuad2967
    @ashrafulfuad2967 Před 6 lety

    Thanks I am a Bangladeshi student

  • @patrickdanser270
    @patrickdanser270 Před 5 lety

    DFS GOD

  • @jahanzaibshahid07
    @jahanzaibshahid07 Před 6 lety +2

    what the hack is going on man

  • @furizagold
    @furizagold Před rokem

    i love u

  • @bobbysugianto5744
    @bobbysugianto5744 Před 6 lety +1

    A,B,D,E,C,F it should be

  • @Mohammedijas619
    @Mohammedijas619 Před 6 lety +2

    Wrong

  • @MrSaicharan1
    @MrSaicharan1 Před 4 lety

    czcams.com/video/Y40bRyPQQr0/video.html Here comes the D xD

  • @EatCodeTravel
    @EatCodeTravel Před 5 lety

    you are doing absolutely wrong man this is DFS or BFS

  • @Sachinsingh-bj1mf
    @Sachinsingh-bj1mf Před 6 lety +1

    This is not DFS bro

  • @ayhamgheis
    @ayhamgheis Před 5 lety +1

    gay