All pastes #910878 Raw Edit

Something

public text v1 · immutable
·published 2008-02-20 08:26 UTC
rendered paste body
public Node<T> add2(Node<T> rroot, T element){
               if(rroot != null){
                       if(rroot.data.compareTo(element)>0){
                               if(rroot.left == null){
                                       rroot.left = new Node<T>(element,null,null);
                                       return rroot.left;
                               }else{
                                       return add2(rroot.left, element);
                               }
                       }else if(rroot.data.compareTo(element)<0){
                               if(rroot.right == null){
                                       rroot.right = new Node<T>(element,null,null);
                                       return rroot.right;
                               }else{
                                       return add2(rroot.right, element);
                               }
                       }else{
                               return rroot;
                       }
               }else{
                       return rroot;
               }
       }