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.

  1. "false"
  2. "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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -