DEPTH FIRST SEARCH WITH PYTHON
Video Overview & Insights
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.
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! 🕑
Bonus! Using a stack and Python to find unbalanced parenthesis
https://howcode.org/t/using-a-stack-to-find-unbalanced-parenthesis/53
Nice video but you should have walked it's through the code for iterative method also
Go to https://howcode.org for more!
Link to DigitalOcean: http://howco.de/d_ocean
I think every recursive-based algorithm should be explained like that, showing the call stack, the algorithm and an illustration, it gets easy to follow. Everyone should learn call stack and how it works on different ocasions while/before learning recursive algorithms. Excelent video and explanation btw, thanks!
Link to howCode Facebook: http://howco.de/fb
Link to howCode Twitter: http://howco.de/twitter
No proper explanation of creating the nodes
Link to /r/howCode: http://howco.de/reddit
Don't forget to subscribe for more!
Great video man! I really feel you made everything less complicated!
More User Perspectives
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!
@ploterman5May 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!
@sweetphilly2Please do python graphs and other data structures as well as algorithms
@AbhishekKumar-yt4mzclass 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)
Cleanest explanation I've found. Well done!
@dereksparks3764Dude, I can't get over how easy it is to print the different orders by just moving the print statement. Thank you!
@JTNewbyThank you for this! Best and simplest ive seen yet.
@thenidoking3378Can I get access to the code?
@pIbrarBabaractually the best explaintion ive seen after hours of searching for explanations - very informative and easy to follow
@EmceeEditsAmazing explanation 😇
@robinfelix3879Great explanation! Thank you.
@ashutoshlohogaonkar8348Great video
@symbol767Thank you! Very easy to understand for me!
@mariagu9967Man, 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.... <3
@WowMemMomentsGlad you have posted again Francis <3
@ItsIrishPlaysWelcome back! This is interesting.
@dimitar.bogdanovWhat software you use for animation?
@gradientODepth first search? Nah, I prefer bread search first
I'm so tired