StreakPeaked· Practice

ExamsGATETechnical

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

  1. Θ(n)
  2. Θ(log n)
  3. Θ(log* n)
  4. Θ(1)

Correct answer: Θ(log n)

Solution

In a sorted array, we can efficiently find the target integer using binary search, which reduces the search space by half with each comparison, resulting in a time complexity of Θ(log n) to determine if the integer appears more than n/2 times.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →