示例#1
0
        public void BreadthFirstElementDoesNotExist()
        {
            BinaryTree <int> tree = new BinaryTree <int>();

            tree.Root            = new BinaryTreeNode <int>(1);
            tree.Root.Left       = new BinaryTreeNode <int>(2);
            tree.Root.Right      = new BinaryTreeNode <int>(3);
            tree.Root.Left.Left  = new BinaryTreeNode <int>(4);
            tree.Root.Left.Right = new BinaryTreeNode <int>(5);
            tree.BreadthFirstSearch(8);
        }
示例#2
0
        public void BreadthFirstFind()
        {
            BinaryTree <int> tree = new BinaryTree <int>();

            tree.Root            = new BinaryTreeNode <int>(1);
            tree.Root.Left       = new BinaryTreeNode <int>(2);
            tree.Root.Right      = new BinaryTreeNode <int>(3);
            tree.Root.Left.Left  = new BinaryTreeNode <int>(4);
            tree.Root.Left.Right = new BinaryTreeNode <int>(5);
            int expected = 3;

            Assert.AreEqual(expected, tree.BreadthFirstSearch(3));
        }
示例#3
0
        public void BreadthFirstFindBiggerTree()
        {
            BinaryTree <int> tree = new BinaryTree <int>();

            tree.Root                  = new BinaryTreeNode <int>(1);
            tree.Root.Left             = new BinaryTreeNode <int>(2);
            tree.Root.Right            = new BinaryTreeNode <int>(3);
            tree.Root.Left.Left        = new BinaryTreeNode <int>(4);
            tree.Root.Left.Right       = new BinaryTreeNode <int>(5);
            tree.Root.Left.Left.Left   = new BinaryTreeNode <int>(6);
            tree.Root.Left.Left.Right  = new BinaryTreeNode <int>(7);
            tree.Root.Left.Right.Left  = new BinaryTreeNode <int>(8);
            tree.Root.Left.Right.Right = new BinaryTreeNode <int>(9);
            int expected = 9;

            Assert.AreEqual(expected, tree.BreadthFirstSearch(9));
        }
示例#4
0
        public void BreadthFirstOnEmptyTree()
        {
            BinaryTree <int> tree = new BinaryTree <int>();

            tree.BreadthFirstSearch(0);
        }