Ejemplo n.º 1
0
        protected void Add(ref LinkedListBinaryTree <T> child, TreeNode <T> treeNode)
        {
            if (child != null)
            {
                throw new Exception("Child is existed");
            }

            LinkedListBinaryTree <T> tempTree = treeNode as LinkedListBinaryTree <T>;

            if (tempTree == null)
            {
                tempTree = new LinkedListBinaryTree <T>(treeNode.Value);
                TreeNode <T> .Copy(treeNode, tempTree);
            }

            child        = tempTree;
            child.level  = level + 1;
            child.parent = this;

            if (depth == 1)
            {
                depth = 1;
                BubbleDepth();
            }

            ++count;
            BubbleCount(1);
        }
Ejemplo n.º 2
0
        public override TreeNode <T> Clone()
        {
            LinkedListBinaryTree <T> cloneTree = new LinkedListBinaryTree <T>(this.Value);

            if (this.parent == null)
            {
                cloneTree.count        = this.count;
                cloneTree.depth        = this.depth;
                cloneTree.left         = this.left;
                cloneTree.left         = (LinkedListBinaryTree <T>) this.left.Clone();
                cloneTree.right        = (LinkedListBinaryTree <T>) this.right.Clone();
                cloneTree.left.parent  = cloneTree;
                cloneTree.right.parent = cloneTree;
            }
            else
            {
                TreeNode <T> .Copy(this, cloneTree);
            }

            return(cloneTree);
        }