Exams › GATE › Technical
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
- Θ(n)
- Θ(log n)
- Θ(log* n)
- Θ(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 →