GATE / CS ARCHIVE

GATE CSE 1994 / QUESTION 1.7

Binary search recurrence

Algorithms · Searching, Sorting & Selection · Full GATE CSE 1994 paper

GATE 1994, Q1.7 MCQ
Report issue

Searching, Sorting & Selection

Question 1.7, GATE 1994: Which recurrence models worst-case binary search: T(n)=T(n/2)+k, 2T(n/2)+k, T(n/2)+log n, or T(n/2)+n?
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

A binary-search step compares the target with the middle key and discards one half. Only the surviving half is searched recursively, so there is one T(n/2) term, not two. Selecting and comparing the middle item takes constant time in an indexed array, represented by k. Repeated halving reaches a constant-size range after Θ(log n) steps. The recurrence presupposes constant-time midpoint access; a linked-list implementation has different access costs.

Original paper, page 1