I want an algorithm that calculates which element, among two, appears more often than the other in a sorted array. The array will have only two types of elements.
Example : $aaaaaabbb$
I have to find an constant time algorithm. Is it possible? The only thing I could come up with was using stack. Push all $a$'s and pop them with $b$. But it takes $O(n)$ operations. Any better approaches? Need a hint (no solution).