GATE / CS ARCHIVE

GATE CSE 1996 / QUESTION 2.13

Average successful sequential search

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

GATE 1996, Q2.13 2 marks · MCQ
Report issue

Searching, Sorting & Selection

Question 2.13, GATE 1996: A sought item is equally likely to occupy any of n positions in a sequentially searched list. Find the expected comparisons for a successful search.
Tap to enlarge
Your answer
Answer & solution

Answer: D: (n+1)/2 (no official key was published)

If the item occupies position i, searching from the beginning requires i comparisons. Uniform success positions therefore give E[C]=(1+2+…+n)/n. The arithmetic-series sum is n(n+1)/2, so E[C]=(n+1)/2. This is not the unsuccessful-search cost n, because successful searches stop at their target. Nor is it a binary-search logarithm, since the stated algorithm scans sequentially rather than repeatedly halving a sorted range.

Original paper, page 5