Clear
by Isai Damier, Android Engineer @ Google

/****************************************************************
 * Author: Isai Damier
 * Title: clear
 * Project: geekviewpoint
 * Package: algorithms
 *
 * Time Complexity of Solution:
 *   Best = Average = Worst = const.
 *
 ***************************************************************/ 
 public void clear() {
  root = null;
}
import org.junit.Test;
import static org.junit.Assert.*;

public class BSTTest {

 /**
   * Test of clear method, of class BST.
   */
  @Test
  public void testClear() {
    System.out.println(""clear"");
    BST bst = new BST();

    assertEquals(true, bst.isEmpty());
    assertEquals(0, bst.size());

    int[] treeTape = {200, 100, 300, 50, 150, 250, 350, 25, 75, 125,
      175, 225, 275, 325, 375, 35, 212, 312, 400};
    //load data into tree
    for (int i : treeTape) {
      bst.add(i);
    }

    assertEquals(false, bst.isEmpty());
    assertEquals(treeTape.length, bst.size());
    for (int i : treeTape) {
      assertNotNull(bst.find(i));
    }

    bst.clear();

    assertEquals(true, bst.isEmpty());
    assertEquals(0, bst.size());
    for (int i : treeTape) {
      assertNull(bst.find(treeTape[0]));
    }

  }
}