Exemplo n.º 1
0
        public void BinarySearchTest()
        {
            /*
             *    5
             *   / \
             *  3   6
             * /  \
             * 2   4
             * /
             * 1
             */

            BinarySearchTree <int> bst = new BinarySearchTree <int>();

            bst.AddChild(5);
            bst.AddChild(3);
            bst.AddChild(2);
            bst.AddChild(6);
            bst.AddChild(1);
            bst.AddChild(4);

            Assert.AreEqual(4, DFS.FindBinaryTreeNode(bst.root, 4).Value);
            Assert.AreEqual(null, DFS.FindBinaryTreeNode(bst.root, 24));
        }