algorithm to find the three majority elements in an array
Posted
by
Qiang Li
on Stack Overflow
See other posts from Stack Overflow
or by Qiang Li
Published on 2011-11-21T01:04:47Z
Indexed on
2011/11/21
1:50 UTC
Read the original article
Hit count: 114
algorithm
Let's say there are three elements in a non-sorted array all of which appear more than one-fourth times of the total number of elements.
What is the most efficient way to find these elements? Both for non-online and online versions of this question.
Thank you!
Edit
The non-online version I was referring to is: this array is specified in full. The online version means the array elements are coming one at a time.
I require the space in addition to time complexity to be tight.
disclaimer: THIS IS NOT HOMEWORK! I consider this as research-level question.
© Stack Overflow or respective owner