コード例 #1
0
        public BinarySearchTreeNode Insert(BinarySearchTreeNode root, int data)
        {
            if (root == null)
            {
                root = new BinarySearchTreeNode(data);
                return(root);
            }

            if (data < root.GetBinarySearchTreeNodeData())
            {
                root.SetBinarySearchTreeNodeLeft(Insert(root.GetBinarySearchTreeNodeLeft(),
                                                        data));
            }
            else
            {
                root.SetBinarySearchTreeNodeRight(Insert(root.GetBinarySearchTreeNodeRight(),
                                                         data));
            }

            return(root);
        }
コード例 #2
0
 public void SetBinarySearchTreeRoot(BinarySearchTreeNode binarySearchTreeNode)
 {
     root = binarySearchTreeNode;
 }
コード例 #3
0
 public void SetBinarySearchTreeNodeRight(BinarySearchTreeNode binarySearchTreeNode)
 {
     right = binarySearchTreeNode;
 }
コード例 #4
0
 public BinarySearchTree(BinarySearchTreeNode binarySearchTreeNode)
 {
     root = binarySearchTreeNode;
 }
コード例 #5
0
 public void SetBinarySearchTreeNodeLeft(BinarySearchTreeNode binarySearchTreeNode)
 {
     left = binarySearchTreeNode;
 }