GATE / CS ARCHIVE

GATE CSE 2025 SET 2 / QUESTION 41

GATE CSE 2025 Set 2 Q41

Algorithms · Searching, Sorting & Selection · Full GATE CSE 2025 Set 2 paper

GATE 2025 Set 2, Q41 2 marks · MCQ
Report issue

Searching, Sorting & Selection

Question 41, GATE 2025: An array A[1…n] has distinct elements and is bitonic: for some 1≤i≤n, A[1…i] is increasing and A[i+1…n] is decreasing. The boundary comparison is not specified. Find the best possible worst-case comparison bound for searching for a supplied key.
Options: A. Θ(n); B. Θ(1); C. Θ((log n)²); D. Θ(log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Distinctness makes the two monotone parts strict. At the partition boundary, if A[i]<A[i+1], the peak is i+1; otherwise it is i. Thus the array has a single peak, including the possible endpoint peaks of a purely increasing or decreasing array.

Find that peak with binary search on adjacent values. Maintain a candidate interval [lo,hi]. For mid<hi, if A[mid]<A[mid+1], the peak lies strictly to the right of mid; otherwise it lies at mid or to its left. Each comparison discards roughly half the interval, taking O(log n) comparisons. Then binary-search the increasing part in its normal order and the decreasing part with reversed comparison direction. Each search costs O(log n), so their sum, plus peak finding, remains O(log n), not O((log n)²).

For a lower bound, sorted arrays are included among bitonic arrays. In the comparison model, exact membership among n distinct ordered keys has n possible successful positions and requires Ω(log n) comparisons in the worst case. Therefore the attainable bound is Θ(log n): D.

Original paper, page 31 · Answer key