Suppose that, given an n-element multiset A (not sorted), we want an O(n) time algorithm for determining whether A contains a majority element, i.e., an element that occurs
I don't know if you've seen this one, but it may help to give you ideas:
Suppose you know there is a majority element in an array L.
One way to find the element is as follows:
Def FindMajorityElement(L):
Count = 0
Foreach X in L
If Count == 0
Y = X
If X == Y
Count = Count + 1
Else
Count = Count - 1
Return Y
O(n) time, O(1) space