Skip to content
GATEiit

GATE DA 2026 Q31: Worst-case comparisons in binary search of 1000 elements

Question

Let A\mathbf{A} be a sorted array containing 1000 distinct integers. You perform a recursive binary search on A\mathbf{A} to find an element y\mathbf{y}. Suppose each comparison checks whether the middle element computed during the current recursive step is equal to, less than, or greater than y\mathbf{y}.

The maximum number of comparisons that may have to be performed if y\mathbf{y} is not an element of A\mathbf{A} is _______. (Answer in integer)

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 10 (official GATE 2026 final answer key)

Concept used: An unsuccessful binary search makes ⌊log⁡2n⌋+1\lfloor \log_2 n \rfloor + 1 comparisons in the worst case.

First step: 29=512≤1000<1024=2102^9 = 512 \le 1000 < 1024 = 2^{10}, so ⌊log⁡21000⌋=9\lfloor \log_2 1000 \rfloor = 9.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2026 DA question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key