アルゴリズム---------------接頭辞ツリー

1424 ワード

/**
 * @ Auther:   
 * @ Date:2019/4/30
 * @ Description:algorithm_code
 * @ version:1.0
 */
public class QIan_Zhui_Shu {
    /**
     *    -------------    -------------------------------
     *                      
     *         :  Node     int cross
     *                        int  end
     *                        Node node[] =new Node[26];  26       
     *          :            char  z         ,       ,    
     *                  char cross+1         cross+1   end++
     *
     *        :   1.     
     *              2.               end 
     *              3.                  cross
     *              4.      cross-- end --
     *
     *
     */


        int cross;
        int end;
        QIan_Zhui_Shu next[];
        public QIan_Zhui_Shu() {
            cross = 0;
            end = 0;
            next  =new QIan_Zhui_Shu[26];
        }


    public  void add(String str,QIan_Zhui_Shu next){
         char temp[] =str.toCharArray();
         for(int i=0;i