Solution: Majority Element

Solution for the Majority Element Problem.

We'll cover the following...

Naive solution

Here is the naive algorithm for solving the Majority Element Problem with quadratic running time:


 MajorityElement(A[1..n])MajorityElement(A[1..n]):
 for ii from 11 to nn:
  currentElementcurrentElement \leftarrow A[i]A[i]
   ...