コード例 #1
0
ファイル: TreesTests.cs プロジェクト: hadesmeza/Playground
        public void TestBinTreeHeigthDepth()
        {
            var bintree = new BinTree<int>(1);
            bintree.AddLeft(2);
            bintree.AddRight(3);
            bintree.AddLeft(4);
            bintree.AddRight(7);
            bintree.Root.Left.AddRight(bintree.Root.Left, new BinTreeNode<int>(5));
            bintree.Root.Right.AddLeft(bintree.Root.Right, new BinTreeNode<int>(6));

            var d = bintree.GettreeDepth();
            var h = bintree.GettreeHeigth();

            Assert.IsTrue(d == 3);
            Assert.IsTrue(h == 2);
        }
コード例 #2
0
ファイル: TreesTests.cs プロジェクト: hadesmeza/Playground
        public void TestBinTreeAddRight()
        {
            var bintree = new BinTree<int>(8);
            bintree.AddRight(5);
            bintree.AddRight(6);
            bintree.AddRight(7);
            bintree.AddRight(8);
            bintree.AddRight(9);
            Assert.IsTrue(bintree.Root.Right.Data == 5);
            Assert.IsTrue(bintree.Root.Right.Right.Data == 6);
            Assert.IsTrue(bintree.Root.Right.Right.Right.Data == 7);
            Assert.IsTrue(bintree.Root.Right.Right.Right.Right.Data == 8);
            Assert.IsTrue(bintree.Root.Right.Right.Right.Right.Right.Data == 9);
            var d = bintree.GettreeDepth();
            var h = bintree.GettreeHeigth();

            Assert.IsTrue(d == 6);
            Assert.IsTrue(h == 5);
        }