An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons

A.

At least 2n-c comparisons, for some constant c, are needed.

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:

A.

Θ(n)

B.

Θ(logn)

C.

Θ(log*n)

D.

Θ(1)

Answer: Option B

Explanation:

Since it is a sorted array, we can use binary search to identify the position of the first occurrence of the given integer in (logn) steps. If at all these integer repeats, its appearance has to be continuous because the array is sorted.