StreakPeaked· Practice

ExamsGATETechnical

An array A of length n with distinct elements is said to be bitonic if there is an index 1 ≤ i ≤ n such that A[1..i] is sorted in the non-decreasing order and A[i + 1..n] is sorted in the non-increasing order. Which ONE of the following represents the best possible asymptotic bound for the worst-case number of comparisons by an algorithm that searches for an element in a bitonic array A?

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

Correct answer: Θ(log n)

Solution

The correct option is Θ(log n) because a bitonic array can be efficiently searched using a modified binary search approach. This method allows us to find the peak element in logarithmic time, and then we can perform binary searches on the two sorted halves, resulting in an overall search time of Θ(log n).

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →