public void DepthFirstElementDoesNotExist() { 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.DepthFirstSearch(8); }
public void DepthFirstFind() { 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 = 5; Assert.AreEqual(expected, tree.DepthFirstSearch(3)); }
public void DepthFirstFindBiggerTree() { 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 = 6; Assert.AreEqual(expected, tree.DepthFirstSearch(5)); }
public void DepththFirstOnEmptyTree() { BinaryTree <int> tree = new BinaryTree <int>(); tree.DepthFirstSearch(0); }