There can be a simple check.

For any element to occur n/k times or more .It has occur atleast once in
every subset of (n/k)+1 size.So we take a window of n/k+1 size and set the
hash of every number equal to 1.These are the only probable elements which
can occur n/k times or more.
We move the window by n/k+1 step and increase the count of only those
elements which occured in the first window.The element which has occured at
least once in all the windows will be occuring atleast n/k times.

Complexity: Total windows: <=k, window size is (n/k)+1.Gives O(k*n/k)=O(n)
time and space complexity = O((n/k)+1).

On Tue, Dec 21, 2010 at 10:02 PM, Saurabh Koar <[email protected]>wrote:

> Use count sort logic.It will be O(n). Bt space complexity matters there.
>
> --
> 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.
>
>


-- 
Thanks & Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science & Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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