@Decipher

As far as I understand the problem it says "returns the 5 most common
occuring strings in a list", and the example u give is of a character array,
when u go to a list of strings with len_of_each_string > 1, u wil have to
*hash* them, which is when u will run into problems with count sort. So
count sort wil not work.

As juver++ said sorting is one option.
Going for hashing of each string and using a hashtable is another possible
solution.
Also building a compressed Trie out of the list and a traversal of it, will
give the top 5 counts (but this will be too much work for this task :) )


Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks
of Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the "scripture" of this age.


On Sat, Jan 8, 2011 at 1:59 AM, Decipher <[email protected]> wrote:

> We can apply count sort here also and take the range of numbers as
> 256 . Example take an array c[256] , where c[i] gives the number of
> times i_th ASCII value is repeated . Then after you have obtained
> c[256] . Check for maximum 5 nos. in this array (which can be done in
> O(n) time and space).
>
> --
> 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]<algogeeks%[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.

Reply via email to