I am working on code that will print out the words contained in a trie and note the amount of times that the word occurred. I thought the most effective way would be for a letter to be stored in the element of the relevant node when a word is added to the trie. Occurrences is basically a flag to signal the end of a word, and is incremented if it is the last letter of a word (indicating the word count).
My struggle at this point is how to get the loop to check all of the children of a node, rather than in a straight line as it is doing right now, but I can't visualize how it would work. Ideas?
struct Node{
char letter;
struct Node children[26];
int occurences;
};
printTrie(struct node root){
int i = 1;
while(root[i] != NULL){
fprint(root.letter);
printTrie(root->children[]);
}
i++;
}