Haha.. I got the query.. U wanna check this Google
Suggestion implemention.. :)
Well, the code seems fairly true.. use recursive approach.. (thats how G
generally uses )
Here it is..
Search (struct trie *node)
{
for(i=0;i<26;i++)
{
if(!node->islast) {
Search(current->CHILDREN[i]);
}
cout<<" "<<current->CHILDREN[i]->letter;
}
}
On Thu, Jun 28, 2012 at 1:58 PM, deepikaanand <[email protected]>wrote:
> @Prem
> I know the implementation of trie...But I have doubt that say I have
> struct trie * current..
> and input = "abc"...The last character matched with head->CHILDREN[i]-
> >letter will be 'c'... now "current" points to c....
>
>
>
>
> next step- there will be 4 branches from
> 'c'..."de","xyz","efgh","pqr"...
> Now if write
> for(i=0;i<26;i++)
> {
> if (current->CHILDREN[i]!=NULL && current->islast==0)
> {
> cout<<" "<<current->CHILDREN[i]->letter; //d e
> current = current->CHILDREN[i];//head now points to 'e'
> }
> }
>
>
>
>
> ////The problem I am facing is how to take back current pointer to
> 'c'
> so that now I get "efgh" as output...and secondly how can I make sure
> that this time 'd' node is not selected again???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.