i have fixed your code.... but it is alwayz better to use recursive function for creating trie. i have wrote my own recursive function to create TRIE... you can understand the same bcozz iterative one make thing unnecessary complicated.
here check the code link :- http://ideone.com/6HhFZ have fun :) :) On 6/28/12, deepikaanand <[email protected]> wrote: > //Taken from careercup.com > > Design the autocomplete feature (ex:Google Suggest) > > I assumed {"abcde","abcegh","abcpqr","abcxyz","xyz" ,"abcmno"} URLs > and stored them in trie...Such if the user enters abc ...the o/p will > be > > abc is a prefix in 5 number of cases > d e > e g h > m n o > p q r > x y z > > > Now say if I add more strings of the form abcdpqr,"abcdprst"..How can > I modify this code such that now thw o/p is > > d e > e g h > m n o > p q r > x y z > d p q r > d p r s t > > code in c :- > http://ideone.com/rBvQb > > -- > 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.
