示例#1
0
        public BST Insert(int value)
        {
            if (this.value > value)
            {
                if (left == null)
                {
                    left = new BST(value);
                }
                else
                {
                    left.Insert(value);
                }
            }
            else if (this.value < value)
            {
                if (right == null)
                {
                    right = new BST(value);
                }
                else
                {
                    right.Insert(value);
                }
            }
            else if (this.value == value)
            {
                if (right == null)
                {
                    right = new BST(value);
                }
                else
                {
                    right.Insert(value);
                }
            }

            return(this);
        }
示例#2
0
        static BST CreateBST2()
        {
            BST root = new BST(1);

            return(root);
        }