You are viewing a single comment's thread. Return to all comments →
def preOrder(root): stack = [root] visited = [] while stack: node = stack.pop() visited.append(str(node)) if node.right: stack.append(node.right) if node.left: stack.append(node.left) print(' '.join(visited))
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Preorder Traversal
You are viewing a single comment's thread. Return to all comments →