Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python depth first search

# left to right, pre-order depth first tree search, recursive. O(n) time/space
def depthFirstSearchRec(root):
    if root == None: return
    print(root)
    depthFirstSearch(root.left)
    depthFirstSearch(root.right)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #python #depth #search
ADD COMMENT
Topic
Name
5+1 =