Beispiel #1
0
        internal void PrintButtom(bnode node)
        {
            if (node.left == null && node.right == null)
            {
                path.Add(node.data);
                return;
            }

            if (node.left != null)
            {
                PrintButtom(node.left);
            }
            if (node.right != null)
            {
                PrintButtom(node.right);
            }
            return;
        }
Beispiel #2
0
        public bnode Build(int[] pre, int[] ino, int s, int e)
        {
            if (s > e)
            {
                return(null);
            }

            bnode node = new bnode(pre[curInd++]);

            if (s == e)
            {
                return(node);
            }
            var inIndex = Search(ino, s, e, node.data);

            node.left  = Build(pre, ino, s, inIndex - 1);
            node.right = Build(pre, ino, inIndex + 1, e);
            return(node);
        }