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'的減法的目的是什麼?