void Trie::Insert(char x[]) { TrieNode *current = root; int i = 0; while ( x[i] != '\0' ) { int j = x[i] - 'a'; if ( current->GetPtr(j) == 0 ) current->SetPtr(j, new TrieNode()); current = current->GetPtr(j); i = i + 1; } current->SetStrEnds(); }
int Trie::Count(){ int counter = 0; for(int i=0;i<TrieMaxElem;i++) counter = counter + Count(root->GetPtr(i), i, false, 1); return counter; }