Exemple #1
0
 private bool IsWithinBoundary(BinarySearchTreeNode node, int leftBoundary, int rightBoundary) =>
 leftBoundary <= node.Value && node.Value <= rightBoundary;
Exemple #2
0
 private bool IsLeaf(BinarySearchTreeNode node) =>
 node != null && node.Left == null && node.Right == null;
Exemple #3
0
 private bool IsBinarySearchTree(BinarySearchTreeNode node)
 {
     return(CheckBinarySearchTree(node, int.MinValue, int.MaxValue));
 }
Exemple #4
0
        public void TestBinarySearchTree(bool expected, BinarySearchTreeNode root)
        {
            var actual = IsBinarySearchTree(root);

            Assert.Equal(expected, actual);
        }
Exemple #5
0
 public BinarySearchTreeNode InsertRight(int rightValue)
 {
     Right = new BinarySearchTreeNode(rightValue);
     return(Right);
 }
Exemple #6
0
 public BinarySearchTreeNode InsertLeft(int leftValue)
 {
     Left = new BinarySearchTreeNode(leftValue);
     return(Left);
 }