Find the repeated element

Given n elements find all the elements that appear morethan n/2 times.
Solve the same for elements appear n/4 times.

Should not use more than const memory and O(n) time.