Exemple #1
0
        public void TestTwo()
        {
            Tree tree = new Tree(1);

            tree.l     = new Tree(2);
            tree.r     = new Tree(3);
            tree.l.l   = new Tree(4);
            tree.l.r   = new Tree(5);
            tree.r.r   = new Tree(8);
            tree.r.r.l = new Tree(6);
            tree.r.r.r = new Tree(7);

            Assert.AreEqual(4, BinaryTreeWidth.GetHeightOfTree(tree));
            Assert.AreEqual(3, BinaryTreeWidth.MaxLevelWidthSolution(tree));
            Assert.AreEqual(8, BinaryTreeWidth.AllNodeCountSolution(tree));
        }
Exemple #2
0
        public void TestOne()
        {
            Tree root = new Tree();//root

            root.x     = 8;
            root.l     = new Tree(); //1stlevel
            root.l.x   = 2;
            root.r     = new Tree(); //1stlevel
            root.r.x   = 6;
            root.r.l   = null;
            root.r.r   = null;
            root.l.l   = new Tree(); //2ndlevel
            root.l.l.x = 8;
            root.l.r   = new Tree(); //2ndlevel
            root.l.r.x = 7;

            Assert.AreEqual(2, BinaryTreeWidth.MaxLevelWidthSolution(root));
            Assert.AreEqual(5, BinaryTreeWidth.AllNodeCountSolution(root));
            Assert.AreEqual(3, BinaryTreeWidth.GetHeightOfTree(root));
        }
Exemple #3
0
        public void TestSimpleWidth()
        {
            Tree root = new Tree()
            {
                x = 0
            };                               //root

            root.l = new Tree()
            {
                x = 1
            };                            //1stlevel
            root.r = new Tree()
            {
                x = 2
            };                            //1stlevel

            Assert.AreEqual(2, BinaryTreeWidth.GetWidthOfLevel(root, 2));
            Assert.AreEqual(2, BinaryTreeWidth.GetHeightOfTree(root));
            Assert.AreEqual(2, BinaryTreeWidth.MaxLevelWidthSolution(root));
            Assert.AreEqual(3, BinaryTreeWidth.AllNodeCountSolution(root));
        }