@Test public void testBinarySearch() { for (int i = 1; i < 6; i++) { Assert.assertNotNull(Searcher.binarySearch(binTree, i)); } Assert.assertNull(Searcher.binarySearch(binTree, 10)); BinaryTreeNode<Integer> four = Searcher.binarySearch(binTree, 4); Assert.assertNotNull(four); Assert.assertFalse(four.isLeaf()); Assert.assertNull(four.leftChild()); Assert.assertNotNull(four.rightChild()); Assert.assertEquals(Integer.valueOf(5), four.rightChild().data()); BinaryTreeNode<Integer> five = Searcher.binarySearch(binTree, 5); Assert.assertTrue(five.isLeaf()); }
public static <E extends Comparable<E>> BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, BinaryTreeNode<E> startNode, E value) { if (startNode == null || value.equals(startNode.data())) { return startNode; } if (value.compareTo(startNode.data()) < 0) { return binarySearch(binTree, startNode.leftChild(), value); } return binarySearch(binTree, startNode.rightChild(), value); }
Searcher { public static <E extends Comparable<E>> BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, BinaryTreeNode<E> startNode, E value) { if (startNode == null || value.equals(startNode.data())) { return startNode; } if (value.compareTo(startNode.data()) < 0) { return binarySearch(binTree, startNode.leftChild(), value); } return binarySearch(binTree, startNode.rightChild(), value); } }
Searcher { public static <E extends Comparable<E>> BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, BinaryTreeNode<E> startNode, E value) { if (startNode == null || value.equals(startNode.data())) { return startNode; } if (value.compareTo(startNode.data()) < 0) { return binarySearch(binTree, startNode.leftChild(), value); } return binarySearch(binTree, startNode.rightChild(), value); }  }
Searcher { public static <E extends Comparable<E>> BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, BinaryTreeNode<E> startNode, E value) { if (startNode == null || value.equals(startNode.data())) { return startNode; } if (value.compareTo(startNode.data()) < 0) { return binarySearch(binTree, startNode.leftChild(), value); } return binarySearch(binTree, startNode.rightChild(), value); }  static BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, E value); static BinaryTreeNode<E> breadthFirstSearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> breadthFirstSearch(BinarySearchTree<E> binTree, E value); static BinaryTreeNode<E> depthFirstSearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> depthFirstSearch(BinarySearchTree<E> binTree, E value); }
Searcher { public static <E extends Comparable<E>> BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, BinaryTreeNode<E> startNode, E value) { if (startNode == null || value.equals(startNode.data())) { return startNode; } if (value.compareTo(startNode.data()) < 0) { return binarySearch(binTree, startNode.leftChild(), value); } return binarySearch(binTree, startNode.rightChild(), value); }  static BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> binarySearch(BinarySearchTree<E> binTree, E value); static BinaryTreeNode<E> breadthFirstSearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> breadthFirstSearch(BinarySearchTree<E> binTree, E value); static BinaryTreeNode<E> depthFirstSearch(BinarySearchTree<E> binTree,
			BinaryTreeNode<E> startNode, E value); static BinaryTreeNode<E> depthFirstSearch(BinarySearchTree<E> binTree, E value); static final Logger LOGGER; }