GATE / CS ARCHIVE

GATE CSE 2021 SET 2 / QUESTION 8

GATE CSE 2021 Set 2 Q8

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

GATE 2021 Set 2, Q8 1 mark · MCQ
Report issue

Searching, Sorting & Selection

Question 8, GATE 2021: What is the worst-case number of arithmetic operations in recursive binary search on a sorted n-element array? A Θ(√n); B Θ(log₂ n); C Θ(n²); D Θ(n).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Each binary-search call performs constant arithmetic and reduces the remaining interval by roughly one half. The worst-case recurrence is T(n)=T(n/2)+Θ(1), so Θ(log n), B, under the standard unit-cost arithmetic model.

After j unsuccessful comparisons, at most about n/2j candidates remain. Reaching one candidate needs j≈log₂n. A call computes a midpoint and adjusts bounds using a constant number of arithmetic operations. This counts operations, not bit complexity of arbitrary-precision index arithmetic.

Original paper, page 59 · Answer key