Find
by Isai Damier

/*****************************************************************
 * Author: Isai Damier
 * Title: Find
 * Project: geekviewpoint
 * Package: algorithms
 *
 * Time Complexity of Solution:
 *   Best = const; Average = O(log(n)); Worst = O(n).
 *
 ****************************************************************/ 
 public Node find(int el) {
  Node n = root;
  while (null != n && el != n.data) {
    if (el > n.data) {
      n = n.right;
    } else {
      n = n.left;
    }
  }
  return n;
}
import org.junit.Test;
import static org.junit.Assert.*;

public class BSTTest {

 /**
   * Test of find method, of class BST.
   */
  @Test
  public void testFind() {
    int el = 7;
    BST bst = new BST();
    assertNull(bst.find(el));
    bst.add(el);
    assertNotNull(bst.find(el));
  }
}