public IEnumerator InOrderTraversal()
{
BinaryTreeNode current = Head;
Stack> stack = new Stack>();
stack.Push(null);
while (stack.Count != 0)
{
while (current != null)
{
stack.Push(current);
current = current.Left;
}
current = stack.Pop();
if (current != null)
{
yield return current.Value;
current = current.Right;
}
}
}
{
BinaryTreeNode
Stack
stack.Push(null);
while (stack.Count != 0)
{
while (current != null)
{
stack.Push(current);
current = current.Left;
}
current = stack.Pop();
if (current != null)
{
yield return current.Value;
current = current.Right;
}
}
}
No comments:
Post a Comment