DEPTH FIRST SEARCH WITH PYTHON

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 พ.ย. 2024

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

  • @howCode
    @howCode  3 ปีที่แล้ว +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 2 ปีที่แล้ว +18

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

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

    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 10 หลายเดือนก่อน

    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!

  • @amjadattar86
    @amjadattar86 2 ปีที่แล้ว +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 ปีที่แล้ว

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

    • @sangaranaarayananr3134
      @sangaranaarayananr3134 11 หลายเดือนก่อน

      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

  • @hawundlovu2096
    @hawundlovu2096 9 หลายเดือนก่อน

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

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

    Glad you have posted again Francis

  • @sweetphilly2
    @sweetphilly2 ปีที่แล้ว +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!

  • @dimitar.bogdanov
    @dimitar.bogdanov 3 ปีที่แล้ว +3

    Welcome back! This is interesting.

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

    Cleanest explanation I've found. Well done!

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

    Thank you! Very easy to understand for me!

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

    Great explanation! Thank you.

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

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

  • @AbhishekKumar-yt4mz
    @AbhishekKumar-yt4mz ปีที่แล้ว

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

  • @NoName-kx3fs
    @NoName-kx3fs 3 ปีที่แล้ว +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....

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

    Can I get access to the code?

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

    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)

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

    Amazing explanation 😇

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

    Thank you

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

    Great video

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

    What software you use for animation?

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

      I make Keynote presentations and just record them 👍

  • @rithannandakumar6163
    @rithannandakumar6163 4 หลายเดือนก่อน

    No proper explanation of creating the nodes

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

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

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

      Lol, "bread" search first