我正在尝试计算trie树中的所有子树,但是该函数什么也不返回,并且程序进入了无限循环,输入键仅是'a'到'z'以及小写字母。对于输入“ arma “,” armata“,” zi“,” zinc“返回325,而不是11
struct TrieNode
{
struct TrieNode *children[ALPHABET_SIZE];
bool isEndOfWord;
};
int subtree(struct TrieNode *root)
{
int count=0;
for(int i = 0 ; i != ALPHABET_SIZE ; i++)
{
if(!root->isEndOfWord)
{
for(int j=i+1;j != ALPHABET_SIZE;j++)
{
count++;
}
root->isEndOfWord=false;
}
}
return count;
}