Finding the majority element of an array
Given an array of N elements, the majority element is defined as the one which occurs more than N/2 times. One simple approach is to find the mode (which appears for most number of times) and check if its frequency is greater than N/2. Three strategies for finding the mode are discussed in my previous…