输入一组不同整型数,将其进行二叉排序,将此二叉排序树生成
一个XML文档bst.xml;如果插入一个整型数,不能影响二叉排序结构;
输入一组不同整型数,将其进行二叉排序,单单这步骤我就愿意给很多分了,希望高手们帮忙。

解决方案 »

  1.   

    在页面jsp和在Java main()主函数里做皆可
      

  2.   

    http://blog.csdn.net/lazy_p/archive/2010/04/08/5460674.aspx
    这是一道二叉排序树的题,希望对你有所帮助
      

  3.   

    在JAVA中实现二叉树,程序如下   public class BinaryTreeTest  
       
       {  
       
      public static void main(String args[])  
       
       {  
       
      BinaryTreeTest b=new BinaryTreeTest();  
       
      int data[]={12,11,34,45,67,89,56,43,22,98};  
       
       BinaryTree root =new BinaryTree(data[0]);  
       
       System.out.print("二叉树的中的数据:  ");  
       
      for(int i=1;i<data.length;i++)  
       
       {  
       
       root.insertTree(root,data[i]);  
       
       System.out.print(data[i-1]+";");  
       
       }  
       
       System.out.println(data[data.length-1]);  
      
     int key=Integer.parseInt(args[0]);  
       
      if(b.searchkey(root,key))  
       
       {  
       
      System.out.println("找到了:"+key);  
       
       }  
       
      else  
       
       {  
       
      System.out.println("没有找到:"+key);  
       
       }  
       
      }  
       
      public boolean searchkey(BinaryTree root, int key)  
       
       {  
       
      boolean bl=false;  
       
      if(root==null)  
       
       {  
       
      bl=false;  
       
      return bl;  
       
       }  
       
      else if(root.data==key)  
       
       {  
       
      bl=true;  
       
      return bl;  
       
       }  
       
      else if(key>=root.data)  
       
       {  
       
      return searchkey(root.rightpoiter,key);  
       
       }  
       
      return searchkey(root.leftpoiter,key);  
       
       }  
       
      }  
       
      class BinaryTree  
       
       {  
       
      int data;  
       
       BinaryTree leftpoiter;  
       
       BinaryTree rightpoiter;  
       
       BinaryTree(int data)  
       
       {  
       
      this.data=data;  
       
       leftpoiter=null;  
       
       rightpoiter=null;  
       
       }  
       
      public void insertTree(BinaryTree root, int data)  
       
       {  
       
      if(data>=root.data)  
       
       {  
       
      if(root.rightpoiter==null)  
       
       {  
       
      root.rightpoiter=new BinaryTree(data);  
       
       }  
       
      else  
       
       {  
       
       insertTree(root.rightpoiter,data);  
       
       }  
       
      }  
       
      else  
       
       {  
       
      if(root.leftpoiter==null)  
       
       {  
       
      root.leftpoiter=new BinaryTree(data);  
       
       }  
       
      else  
       
       {  
       
       insertTree(root.leftpoiter,data);  
       
       }  
       
      }  
       
       }  
       
      }  
       
      //end