二分搜索树非递归(栈)实现遍历
// 二分搜索树的非递归前序遍历
public void preOrderNR() {
// 声明一个栈,模拟系统栈
Stack<Node> stack = new Stack<>();
stack.push(root);
while (!stack.isEmpty()) {
Node cur = stack.pop();
System.out.println(cur.e);
if (cur.right != null)
stack.push(cur.right);
if (cur.left != null)
stack.push(cur.left);
}
}