2
因此,我正在实现一个用于从文件中读取唯一字的trie。我是如何实现它的在线寻找和整个做的这种方式来: //插入在特里树树 “利用trie数据结构
void insert(struct node *head, string str)
{
int i, j;
for(i = 0;i < str.size(); ++i){
//if the child node is pointing to NULL
if(head -> next_char[str[i] - 'a'] == NULL){
struct node *n;
//initialise the new node
n = new struct node;
for(j = 0;j < 26; ++j){
n -> next_char[j] = NULL;
}
n -> end_string = 0;
head -> next_char[str[i] - 'a'] = n;
head = n;
}
//if the child node is not pointing to q
else head = head -> next_char[str[i] - 'a'];
}
//to mark the end_string flag for this string
head -> end_string = 1;
}
从行我的困惑arrise: ”线头 - > next_char [str [i] - 'a'] == NULL 在这段代码实现它的所有方式中使用'a'的减法的目的是什么?