我坚持一个项目,我必须创建一个“字校正器”,我必须使用“Trie数据结构”,事情是我必须从文件中获取单词(我知道如何做)但是我已经实现了这个界面

public interface Trie {

public void add();
public boolean query(String word);
public boolean isEmpty();
}

然后我有一个类 TreeTrie ,它有一个内部类Node

public class TreeTrie implements Trie{

private static int cardinalityAlphabet= 0;
private Node node;
private ArbreTrieTau(int cardinality){
    this.cardinalityAlphabet= cardinality;
}

private class Node{
    Node[] n;
    public Node(int num){
        //+1 because of centinel
        this.n = new Node[num+1];
    }

}

现在我'm stuck because I don'知道如何开始创建树,我的意思是我现在不必构建它,我必须实现方法add,query,isEmpty(),我想在方法上添加它需要一个String字作为查询方法,然后我必须获取该单词的 charAt(0) 并创建它的新节点?我是否必须创建另一个方法将索引0转换为"a",索引1转换为"b"等?

树是这样的:

enter image description here

注意* centinel是数组的最后一项而不是第一项 .

我不能使用列表我必须使用[] .