enqueue root while queue is not empty: dequeue as node enqueue node's subnode
深度优先搜索
利用栈来实现,从根节点出发,发现有子节点未访问过则将子节点入栈。
1 2 3 4 5 6 7 8 9 10
push root while stack is not empty: if left child of stack.top has not been visited: set left child visited push left child else if right child of stack.top has not been visited: set right child visited push right child else: pop stack