The most crude method would be to do a comparison in the entire array list
and increment as and when we find a match.
But this method gives a complexity of O(n2).

The same method above can be used , and comparisons can be done from either
ends of array, which reduces the
complexity to O(n2 / 2)

The last , is we could create a BST with the input, Basically insert the
names in BST, and when we inset we do a comparision
if its already inserted , just increment the count of each name, the
complexity of this method can be O(log n)

Best Regards
Abhijit


On Fri, Oct 15, 2010 at 7:00 AM, Kumar S <[email protected]> wrote:

> Q : A file has list of names. We need an algorithm to find the number each
> names repeats in that list. NOT case sensitive
>
> Example...
>
> namefile.txt has the content......
>
> bob
> abi
> jack
> ram
> jim
> tim
> joey
> riya
> kris
> bob
> kris
> ram
> jack
> joe
> joe
> joey
> bob
> bob
> bob
> kris
> joe
>
>
> this has more than 32000 in the list..  not limited number .
>
> Output : must have the distinct names and the count against them..
>
> Appreciate your inputs.
>
> Thanks n have a good one
>
> --
> 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