二叉樹(shù)中序遍歷(非遞歸)
(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;
}
}
}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。