Question: Design an O(n) algorithm that determines whether or not there is a majority in a list of elements. For example, [3,2,1] is NO and [3,1,3]
Design an O(n) algorithm that determines whether or not there is a majority in a list of elements. For example, [3,2,1] is NO and [3,1,3] is YES.
I want an answer that doesn't require the use of dictionaries/hash maps. It cannot be "Moore's voting algorithm" or a variation of it. The algorithm also can not use linear sorting algorithms because the input can not be assumed to satisfy the required conditions for any of the linear sorting algorithms my professor discussed in class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
