
public class BinarySearchTree {

  private Node root;

  public BinarySearchTree() {
    root = null;
  }

  protected void insert(int key, String data) {
    Node newNode = new Node(key, data);

    /* First node in the tree */
    if (root == null) {
      root = newNode;
      return;
    }

    /* Figure out where to put the newNode*/
    else {
      Node focusNode = root;
      Node parent;

      while(true) {
        parent = focusNode;

        /* newNode goes on the left subtree */
        if (key < focusNode.key) {
          focusNode = focusNode.leftChild;

          if (focusNode == null) {
            parent.leftChild = newNode;
            return;
          }
        }

        /* newNode goes on the right subtree */
        else if (key > focusNode.key) {
          focusNode = focusNode.rightChild;

          if (focusNode == null) {
            parent.rightChild = newNode;
            return;
          }
        }
      }
    }
  }

  protected Node findNode(int key) {
    Node focusNode = root;

    while (focusNode.key != key) {
      if (key < focusNode.key) {
          /* Shift the focusNode left */
          focusNode = focusNode.leftChild;
      }

      else if (key > focusNode.key){
        /* Shift the focusNode right */
        focusNode = focusNode.rightChild;
      }

      if (focusNode == null) {
        return null;
      }
    }
    return focusNode;
  }

  protected void traverseInOrder(Node focusNode) {
    if (focusNode != null) {
      traverseInOrder(focusNode.leftChild);
      System.out.println(focusNode);
      traverseInOrder(focusNode.rightChild);
    }
    return;
  }

  protected void traversePreOrder(Node focusNode) {
    if (focusNode != null) {
      System.out.println(focusNode);
      traversePreOrder(focusNode.leftChild);
      traversePreOrder(focusNode.rightChild);
    }
    return;
  }

  protected void traversePostOrder(Node focusNode) {
    if (focusNode != null) {
      traversePostOrder(focusNode.leftChild);
      traversePostOrder(focusNode.rightChild);
      System.out.println(focusNode);
    }
    return;
  }

}

@@ -1,8 +1,65 @@
+%0A/* Implements the Binary Search Tree data structure. */%0A
 %0Apublic 
@@ -154,24 +154,85 @@
  null;%0A  %7D%0A%0A
+  /* Insert a node with key and data into the binary tree */%0A
   protected 
@@ -1072,24 +1072,129 @@
 %0A    %7D%0A  %7D%0A%0A
+  /* Return the node with key in the binary tree.%0A  Return null if the key is not in the binary tree. */%0A
   protected 
@@ -1318,26 +1318,24 @@
 ) %7B%0A        
-  
 /* Shift the
@@ -1349,26 +1349,24 @@
 ode left */%0A
-  
         focu
@@ -1620,24 +1620,82 @@
 sNode;%0A  %7D%0A%0A
+  /* Perform an in-order traversal on the binary tree. */%0A
   protected 
@@ -1903,32 +1903,90 @@
    return;%0A  %7D%0A%0A
+  /* Perform a pre-order traversal on the binary tree. */%0A
   protected void
@@ -2201,16 +2201,75 @@
 n;%0A  %7D%0A%0A
+  /* Perform a post-order traversal on the binary tree. */%0A
   protec

Comment BST methods.