DEPTH FIRST SEARCH WITH PYTHON

Sdílet
Vložit
  • čas přidán 7. 07. 2024
  • In this video we'll be learning about trees, traversal, depth-first search (DFS) and how we can implement DFS easily using both recursion and iteration.
    Bonus! Using a stack and Python to find unbalanced parenthesis
    howcode.org/t/using-a-stack-t...
    Go to howcode.org for more!
    Link to DigitalOcean: howco.de/d_ocean
    Link to howCode Facebook: howco.de/fb
    Link to howCode Twitter: howco.de/twitter
    Link to /r/howCode: howco.de/reddit
    Don't forget to subscribe for more!

Komentáře • 26

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

    I'll add a new article to howcode.org tomorrow with some extra stuff I didn't have time to talk about in the video, it's a bit late for me at the moment! 🕑

  • @EmceeEdits
    @EmceeEdits Před 2 lety +15

    actually the best explaintion ive seen after hours of searching for explanations - very informative and easy to follow

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

    Dude, I can't get over how easy it is to print the different orders by just moving the print statement. Thank you!

  • @ploterman5
    @ploterman5 Před 5 měsíci

    I have been looking for a easy to follow video on this for some time and finally I have found one. Thank you and keep up the good work!

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

    Glad you have posted again Francis

  • @dereksparks3764
    @dereksparks3764 Před rokem

    Cleanest explanation I've found. Well done!

  • @dimitar.bogdanov
    @dimitar.bogdanov Před 3 lety +3

    Welcome back! This is interesting.

  • @thenidoking3378
    @thenidoking3378 Před 2 lety

    Thank you for this! Best and simplest ive seen yet.

  • @mariagu9967
    @mariagu9967 Před 2 lety +2

    Thank you! Very easy to understand for me!

  • @ashutoshlohogaonkar8348
    @ashutoshlohogaonkar8348 Před 2 lety +2

    Great explanation! Thank you.

  • @hawundlovu2096
    @hawundlovu2096 Před 5 měsíci

    Great video man! I really feel you made everything less complicated!

  • @robinfelix3879
    @robinfelix3879 Před 2 lety

    Amazing explanation 😇

  • @symbol767
    @symbol767 Před 2 lety

    Great video

  • @sweetphilly2
    @sweetphilly2 Před rokem +1

    May be worth adding/mentioning a search term to your functions since these are searching algorithms. It may be obvious for some to just add an if-statement and return some value (i.e. boolean, Node), but definitely not all will know. Great video nonetheless!

  • @nikitaserov8835
    @nikitaserov8835 Před rokem

    Thank you

  • @AbhishekKumar-yt4mz
    @AbhishekKumar-yt4mz Před rokem

    Please do python graphs and other data structures as well as algorithms

  • @NoName-kx3fs
    @NoName-kx3fs Před 3 lety +3

    Man, do more, someday I will learn English enough to watch all your videos !!! I will learn English for you and your fucking great content in the world. ahhhhhhhhhhhhhh....

  • @codingwithmiles2732
    @codingwithmiles2732 Před 3 lety

    I tried creating an empty list and pass it in the walk2 function but I got this error
    TypeError: 'builtin_function_or_method' object is not subscriptable
    any help?
    my code
    #the Stack
    stack = []
    #calling walk2 function
    print("THE ITERATIVE WAY")
    walk2(mytree,stack)

  • @amjadattar86
    @amjadattar86 Před rokem +3

    class Node:
    def __init__(self,value,left = None ,right=None):
    self.value= value
    self.left = left
    self.right = right
    def __str__(self):
    return "Node("+str(self.value)+")"
    def walk(tree):
    if tree is not None:
    print(tree)
    walk(tree.left)
    walk(tree.right)
    def walk2(tree,stack):
    stack.append(tree)
    while len(stack) > 0:
    node = stack.pop()
    if node is not None:
    print(node)
    stack.append(node.right)
    stack.append(node.left)
    mytree = Node('A', Node('B',Node('D'),Node('E')), Node('C',Node('F'),Node('G')))
    walk(mytree)

    • @Democracy_Manifest
      @Democracy_Manifest Před 8 měsíci

      Thank you.
      Also users will need to add stack = [] or stack = deque() to use walk2

    • @sangaranaarayananr3134
      @sangaranaarayananr3134 Před 6 měsíci

      Why we are not having conditions to check whether the left and right are not none. It might reduce some iteration’s right. Correct me if I am wrong please

  • @pIbrarBabar
    @pIbrarBabar Před 2 lety +1

    Can I get access to the code?

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

    What software you use for animation?

    • @howCode
      @howCode  Před 3 lety +3

      I make Keynote presentations and just record them 👍

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

    Depth first search? Nah, I prefer bread search first
    I'm so tired