/*
 Insert(int n) : Add a node the tree with value n. Its O(lgn)

Find(int n) : Find a node the tree with value n. Its O(lgn)

Delete (int n) : Delete a node the tree with value n. Its O(lgn)

Traverse(): Traverse Tree 
 */

/**
 *
 * @author shohan
 * implement Binary Tree
 */

class Node{
    int data;
    Node left;
    Node right;
    
    public Node(int data){
        this.data = data;
        left = null;
        right = null;
    }
}


public class BinarySearchTree {
         Node root;
         
         void insertNode(int id){
             Node newNode = new Node(id);
             if(root == null){ // tree empty 
                 root = newNode;
                 return;
             }
             Node current = root;
             Node parent = null;
             while(true){
                 parent = current;
                 if(id<current.data){ // go left
                        current = current.left; 
                        if(current==null){ // reach the leaf node that has no child
                            parent.left = newNode;
                            return;
                        }
                 }
                 else{ // go right
                     current = current.right;
                     if(current==null){
                         parent.right = newNode;
                         return;
                     }
                 }
             } // end loop
         }
    
         void displayTree(Node root){
             if(root!=null){
                 displayTree(root.left);
                 System.out.print(" "+root.data+" ");
                 displayTree(root.right);
             }
         }
         
         boolean find(int val){
             Node current = root;
                    while(current!=null){
                            if(current.data == val)
                                return true;
                            else if(val<current.data){
                                current = current.left;
                            }
                            else{
                                current = current.right;
                            }
                    }
                    return false;
         }
         
    public static void main(String args[]){
        
      BinarySearchTree myBST = new BinarySearchTree();
      myBST.insertNode(40);
      myBST.insertNode(20);
      myBST.insertNode(30);
      myBST.insertNode(50);
      
      myBST.displayTree(myBST.root);
      if(myBST.find(50) == true){
          System.out.println("Found");
      }
      else{
          System.out.println("Not Found");
      }
    }
}

@@ -122,16 +122,91 @@
  O(lgn)%0D
+%0A                --%3E iterative way %0D%0A                --%3E recursive way    %0D
 %0A%0D%0ADelet
@@ -265,16 +265,78 @@
  O(lgn)%0D
+%0A          (a) : node to be deleted is a leaf node (no child)%0D
 %0A%0D%0ATrave
@@ -865,32 +865,47 @@
              %7D%0D%0A
+             %0D%0A
              Nod
@@ -949,32 +949,47 @@
 parent = null;%0D%0A
+             %0D%0A
              whi
@@ -1933,16 +1933,33 @@
 nt val)%7B
+ // iterative way
 %0D%0A      
@@ -2474,24 +2474,453 @@
 %0A         %0D%0A
+               boolean search(Node root, int id)%7B // recursive way%0D%0A               %0D%0A                if(root == null)%0D%0A                    return false;%0D%0A                else if(root.data == id)%0D%0A                    return true;%0D%0A                else if(id%3Croot.data)%0D%0A                   return search(root.left,id);%0D%0A                else%0D%0A                   return search(root.right,id);                %0D%0A         %7D%0D%0A         %0D%0A
     public s
@@ -3138,24 +3138,24 @@
 );%0D%0A      %0D%0A
-
       myBST.
@@ -3176,24 +3176,32 @@
 BST.root);%0D%0A
+      %0D%0A
       if(myB

implement 2 types searching method