@ashish: your key creation method would need additional space for
converting it into form a2b2c1 in O(n) time . as we all know that a
word length is not very large .....say on avg 15 letters . so we can use
counting sort which is also O(n).

On Sun, May 13, 2012 at 6:05 AM, Ashish Goel <ashg...@gmail.com> wrote:

> while making a multimap is a great idea, instead of sorting the word, the
> key could be formed by using a hash seprately as char and its count as pair
> and then making the string like a2b4c1 as the key, the key would form in
> O(n) too.
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
> On Sat, May 12, 2012 at 1:57 PM, atul anand <atul.87fri...@gmail.com>wrote:
>
>> given the list of words... what you can do is the following :-
>> now take first word from the list..
>> sort this word in alphabetical order...for eg str=bcda ---> sort , we get
>> str=abcd
>> now considering this sorted word as a key(abcd) , insert original word
>> (bcda as value) into the hash table ( hash table with chaining )
>>
>> similarly do it for other words.
>>
>> now given a word , you just need to sort this given word and use it as a
>> key to fetch all anagram.
>>
>>
>>  On Fri, May 11, 2012 at 5:24 PM, mayur <mayursa...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I am stuck with a question for a long time...can someone provide the
>>> best algorithm for this..
>>>
>>> Question).. find all the anagrams in a list of words. The algorithm
>>> should be efficient as the list can be very large.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/algogeeks/-/c4cSIMcBYLEJ.
>>> 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.
>

-- 
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