c - Tries Data Structure - Print All Values -
i want print values in trie data structure, code parts of dictionary program.
void search(struct dictionary **current) { if((*current)->is_end==1){ printf("\n"); getchar(); } for(int i=0; i<26; i++){ if((*current)->children[i]!=null){ printf("%c",i+(int)'a'); search(&(*current)->children[i]); } } }
i want push values.
- "false"
- "fail"
but when run code, program shows: fail lse
the parts "fa" of "false" doesn't showing because recursion doesn't start beginning again if is_end has been marked.
you don't need restart recursion begining every time reach terminal node. can keep buffer current prefix when traverse trie , print entire content every time is_end true.
Comments
Post a Comment