majority element
- From: "ericun***" <xuwenduan2010@xxxxxxxxx>
- Date: 1 Nov 2006 18:22:27 -0800
Dear all,
I have worked out the following algorithm for finding the majority
element(the element occurs more than n/2 times) of an array of n
elements :
Suppose that I have a subroutine that could find the median of an array
in theta(n) time, then:
the algorithm will be:
1.find the median of the array
2.check to see if it's the majority element by a single pass through
the array, and count its occurrence
Now, what if I want to find the element that occurs more than n/m times
in the array, where m is an arbitrary integer?How can I just modify the
above to get this new algorithm?It could be very straightforward, but i
got stuck on this,
Any hints, help appreciated!!
Thanks.
.
- Follow-Ups:
- Re: majority element
- From: David Marcus
- Re: majority element
- Prev by Date: Re: Polynomial rings
- Next by Date: Re: Cantor Confusion
- Previous by thread: Polynomial rings
- Next by thread: Re: majority element
- Index(es):