This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
OlderNewer