@krishna : tracking just second and first longest word would be enough??

what if input has word which is made by repeating small word again and again
test
tester
testertest
testing
testingtester
testtesttesttesttest  // added word

and by saying O(n) .. n= total number of alphabets in the file rite??

On Tue, May 22, 2012 at 7:17 PM, Prem Krishna Chettri <hprem...@gmail.com>wrote:

> Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be
> taken into consideration..
>
> T(O)=O(n) can be done easily.. ( By tracking Second and First Longest word
> found soFar and updating otherwise accordingly)
>
> Can someone do it better?
>
>
> On Tue, May 22, 2012 at 6:15 PM, Ashish Goel <ashg...@gmail.com> wrote:
>
>> write a program to find the longest word made of other words. For
>> instance, If my file has the following words (sorted):
>> test
>> tester
>> testertest
>> testing
>> testingtester
>>
>> The longest word should be testingtester. Trie is the solution, what is
>> the best Order possible?
>> Best Regards
>> Ashish Goel
>> "Think positive and find fuel in failure"
>> +919985813081
>> +919966006652
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to