コード例 #1
0
        public void CheckSubtreeAlgo_WhenT2IsSubtreeOfT1_ReturnsTrue()
        {
            // Arrange
            var t1 = new BinaryTreeNode <int>(3);

            t1.Left            = new BinaryTreeNode <int>(5);
            t1.Right           = new BinaryTreeNode <int>(7);
            t1.Left.Left       = new BinaryTreeNode <int>(8);
            t1.Left.Right      = new BinaryTreeNode <int>(9);
            t1.Right.Left      = new BinaryTreeNode <int>(10);
            t1.Right.Left.Left = new BinaryTreeNode <int>(11);

            var t2 = new BinaryTreeNode <int>(7);

            t2.Left      = new BinaryTreeNode <int>(10);
            t2.Left.Left = new BinaryTreeNode <int>(11);

            // Act
            var actual = CheckSubtree.CheckSubtreeAlgo(t1, t2);

            // Assert
            actual.Should().BeTrue();
        }
コード例 #2
0
        public void CheckSubtreeTestAlternative(TreeNode <int> T1, TreeNode <int> T2, bool expectedResult)
        {
            bool result = CheckSubtree <int> .IsSubtreeWithPreOrderTraversal(T1, T2);

            Assert.Equal(expectedResult, result);
        }
コード例 #3
0
        public void CheckSubtreeTest(TreeNode <int> T1, TreeNode <int> T2, bool expectedResult)
        {
            bool result = CheckSubtree <int> .IsSubtree(T1, T2);

            Assert.Equal(expectedResult, result);
        }