コード例 #1
0
        public void PreOrderTraversal()
        {
            Stack <XBinaryTreeNode> nodeStack = new Stack <XBinaryTreeNode>();
            XBinaryTreeNode         node      = root;

            while (node != null)
            {
                if (node.right != null)
                {
                }
            }
        }
コード例 #2
0
        public void InOrderTraversal()
        {
            Stack <XBinaryTreeNode> nodeStack = new Stack <XBinaryTreeNode>();
            XBinaryTreeNode         node      = root;

            while (node != null && nodeStack.Count > 0)
            {
                while (node != null)
                {
                    nodeStack.Push(node);
                    node = node.left;
                }
                if (nodeStack.Count > 0)
                {
                    node = nodeStack.Pop();
                    Console.Write(node.value);
                    node = node.right;
                }
            }
        }