Skip to content

Instantly share code, notes, and snippets.

View pdarche's full-sized avatar

Peter Darche pdarche

  • Abnormal Security
  • San Francisco, CA
View GitHub Profile
@pdarche
pdarche / depth_first_searcher.py
Created January 13, 2018 01:52
Finds a node in a tree using depth first search
"""
Depth first search code for the Recurse Center!
"""
def search_tree(tree, node, target_node):
""" Finds a node in a tree using depth first search """
if node == target_node:
return target_node
for child_node in tree[node]:
found_node = search_tree(tree, child_node, target_node)