Sorry, that was not really clear. I was just adding the newly found
word to a list of words. That list will be the output. I treated it as
if it was declared globally. It would be better form to pass the list
in as a reference, or to have the function return the list.

Don

On May 29, 12:14 am, rahul sharma <rahul23111...@gmail.com> wrote:
> @don u r searching in a previously built trie with the given filter...then
> wat is this add fxn doing?correct me if m getting u wrngOn Wednesday, May 29, 
> 2013, avinesh saini <avinesh.sa...@gmail.com> wrote:
> > Thank you Don, I was also trying in similar way. But here I'm confused
>
> how you are storing the traversed words. Are you adding whole words at the
> node on which word is ending during insertion.
>
>
>
>
>
>
>
>
>
> > On Wed, May 29, 2013 at 12:36 AM, Don <dondod...@gmail.com> wrote:
>
> >> void findWords(trie *root, char *filter)
> >> {
> >>     if (!root) return;
>
> >>     if (*filter == 0)  // When you reach the end of the filter at the
> >> end of a valid word, add the word.
> >>     {
> >>         if (root->words) words.add(root->word);
> >>     }
> >>     else if (*filter == '.')   // Search for words with any letter
> >>     {
> >>         for(int i = 'a'; i <= 'z' ; ++i)
> >>             findWords(root->link[i], filter+1);
> >>     }
> >>     else  // Search for words with the required letter
> >>     {
> >>          findWords(root->link[*filter], filter+1);
> >>     }
> >> }
>
> >> On May 28, 4:47 am, avinesh saini <avinesh.sa...@gmail.com> wrote:
> >> > How to search all the matching words for a filter in a trie.
> >> > e.g.
> >> > searching by filter  "...r..m" will find all the words(of length = 7)
> in
> >> > trie in which 4th character is 'r' and 7th character is 'm'.
>
> >> > --
> >> > *
> >> > *
> >> > *thanks & regards,*
> >> > *Avinesh
> >> > *
>
> >> --
> >> You received this message because you are subscribed to the Google
>
> Groups "Algorithm Geeks" group.>> To unsubscribe from this group and stop 
> receiving emails from it, send
>
> an email to algogeeks+unsubscr...@googlegroups.com.
>
> > --
>
> > thanks & regards,
> > Avinesh
>
> > --
> > You received this message because you are subscribed to the Google Groups
>
> "Algorithm Geeks" group.> To unsubscribe from this group and stop receiving 
> emails from it, send an
>
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Reply via email to