Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. public void add(T item)
  2.     {
  3.  
  4.         if(item.compareTo(data)<0)
  5.         {
  6.            
  7.             if(leftChild==null)
  8.             {
  9.                 leftChild= new BinaryTreeNode(item);
  10.             }
  11.             else
  12.                 leftChild.add(item);
  13.         }
  14.         else
  15.         {
  16.            
  17.             if(rightChild==null)
  18.                 rightChild=new BinaryTreeNode(item);
  19.             else
  20.                 rightChild.add(item);
  21.         }
  22.            
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement