二叉树中序遍历(非递归)
(2010-03-15 15:50:22) public void MidStackOrder()
{
Stack<Node> stack = newStack<Node>();
Node node = _head;
while (node != null || stack.Count > 0)
{
while (node != null)
{
stack.Push(node);
node = node.left;
}
if (stack.Count > 0)
{
node = stack.Pop();
Console.WriteLine(node);
node = node.right;
}
}
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。