GateAI
Searching, Sorting and Hashing

GATE CSE 2021 Set 2 · Q8

MCQ1 markEasy

Time

What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size nn?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) (log2(n))

Searching, Sorting and Hashing

In a recursive binary search on a sorted array of size nn, each recursive step performs a constant number of arithmetic operations (such as finding the midpoint ⌊(low+high)/2⌋\lfloor (\text{low} + \text{high})/2 \rfloor and index increments/decrements).

The recurrence relation for the number of operations T(n)T(n) in the worst case is:

T(n)=T(⌊n2⌋)+O(1)T(n) = T\left(\left\lfloor \frac{n}{2} \right\rfloor\right) + O(1)

Applying the Master Theorem (or unrolling the recurrence):

T(n)=Θ(log⁡2n)T(n) = \Theta(\log_2 n)

Thus, the worst-case number of arithmetic operations is Θ(log⁡2(n))\Theta(\log_2(n)), which corresponds to option (B).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Searching, Sorting and Hashing previous year question is Q8 of the GATE CSE 2021 Set 2 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Searching, Sorting and Hashing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Searching, Sorting and Hashing in GATE CSE

Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 9 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2021 Set 2.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2021 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2021 Set 2 · Q8 · MCQ

What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.