public void buildDictionary(TrieNode root,String[] words){
        for(int i=0;i<words.length;++i){
            TrieNode cur=root;
            for(int j=0;j<words[i].length();++j){
                TrieNode next=null;
                if((next=cur.getAdj(words[i].charAt(j)))==null){
                    next=new TrieNode(words[i].charAt(j));
                    cur.addAdj(next);
                }
                cur=next;
                if(j==words[i].length()-1) cur.index=i;
            }
        }
    }