/*** 非递归 中序遍历* **/public void InOrderTreeWalk(BSTreeNode<T> root, Action<BSTreeNode<T>> func) {if (root == null) {return;}Stack<BSTreeNode<T>> stack = new Stack<BSTreeNode<T>>((int)(2 * Math.Log(Count + 1)));BSTreeNode<T> current = root;while (current != null) {stack.Push(current);current = current.left;}while (stack.Count != 0) {current = stack.Pop();func(current);BSTreeNode<T> node = current.right;while (node != null) {stack.Push(node);node = node.left;}}}
原文:http://www.cnblogs.com/xiejunzhao/p/6697048.html