前序遍历 借助一个栈,先把根节点压入,当栈不为空是弹栈,依次判断节点有没有右孩子和左孩子,有就压入。因为前序遍历顺序是根左右,所以右孩子要比左孩子先压入栈中。 public static void pre(TreeNode head) { if(head != null) { Stack<TreeNode> s = new Stack(); s.push(head); while(!s.empty()) { head = s.pop(); if