Algorithm NaiveMajorityElement(A: array, N: integer) Input: An array A of size N. Output: The majority element of A, if exist. Otherwise, null. threshold <- N div 2 + 1; // div: integer division. for (i=0 to n-1) // if A[i] is a majority element then count <- 0; for (j-0 to n-1) if (A[i] == A[j]) count++; end for if (count >= threshold) // it is a majority element. return A[i]; end for; return null; O(n2) Best case: one iteration; A[0] is the majority element. Worst case: N iterations; no majority element.