@Sunny..How do u intend to store them in a Tree ? Can you explain ? In a trie u first insert the first word ..take the second word..If its not present in the trie u insert it else remove it from original string .Alternatively u store the elements in a trie in the initial string and terminate it with '\0' and return it . In the worst case trie will take O(n) space where n is the no of letters in the string . and Traversal and creation and search too will take O(n).
How abt Balanced Binary Tree ? On Tue, Oct 11, 2011 at 12:38 AM, sunny agrawal <[email protected]>wrote: > Trie will take too much space.. > Balanced Binary tree can be Better ...?? > > > On Tue, Oct 11, 2011 at 12:16 AM, Ankur Garg <[email protected]> wrote: > >> I think this can be done through tries >> >> Any better solution ? >> >> On Mon, Oct 10, 2011 at 10:59 PM, sachin goyal <[email protected]>wrote: >> >>> remove duplicate words from a string with min. complexityy..... >>> >>> -- >>> 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. >> > > > > -- > Sunny Aggrawal > B.Tech. V year,CSI > Indian Institute Of Technology,Roorkee > > > -- > 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.
