O(n log n) will be trivial.

O(n) is required at any cost. (Consider the case with 501 "1"s and 499
"0"'s)

Ok, so u can make a hashmap with your integer as keys and frequency as the
value.
   No of keys will be between 2 and 500.   (=> Traversing through takes O(n)
)
   You will have to traverse the array exactly once => O(n)
=> O(n) solution.

And it cannot be made better !

--------------------------------------------------
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14


On Wed, Apr 14, 2010 at 4:14 PM, Gauri <[email protected]> wrote:

> Say If I have an array of 1,000 32-bit integers .And one of the value
> is occuring 501 number of times or more in the array. Can someone help
> me devise an efficient algorithm for the same ?
>
> Thanks & Regards
> Gauri
>
> --
> 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