GATE DA 2026 · Linear Search & Binary Search

NAT · 1 mark · Problem PROG-SRCH-0007

Let A be a sorted array containing \(1000\) distinct integers. You perform a recursive binary search on \(\text{A}\) to find an element \(\text{y}\). Suppose each comparison checks whether the middle element computed during the current recursive step is equal to, less than, or greater than \(\text{y}\). The maximum number of comparisons that may have to be performed if \(\text{y}\) is not an element of \(A\) is . (Answer in integer)

Numerical answer (NAT).

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionBinary search on \(1000\) distinct elements halves the search space with each comparison. The number of comparisons needed in the worst case is \(\lceil\log_2(n+1)\rceil\) (or equivalently \(\lfloor\log_2n\rfloor+1\)).\(2^9=512<1000<1024=2^{10}\), so \(\lceil\log_2(1001)\rceil=10\).Answer: 10Click Here for Detail SolutionGateOverflow discussion: https://gateoverflow.in/523194/gate-da-2026-question-21

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com