Algorithms | Misc | Question 5
The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is
whenever there exists an element which is present in the array : more than n/2 times, then definitely it will be present at the middle index position; in addition to that it will also be present at anyone of the neighbourhood indices namely i−1 and i+1
No matter how we push that stream of More than n/2 times of elements of same value around the Sorted Array, it is bound to be present at the middle index + atleast anyone of its neighbourhood once we got the element which should have occurred more that n/2 times we count its total occurences in O(logn) time.
Quiz of this Question
Please comment below if you find anything wrong in the above post