The GATE Grind

GATE 2021 CS (CS2) – Question 18

Algorithms · Searching, Sorting and Hashing · 1 mark · Multiple choice

Find the worst-case number of arithmetic operations in recursive binary search on a sorted n-element array.

  1. Θ(√n)
  2. Θ(log₂n)
  3. Θ(n²)
  4. Θ(n)

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) Θ(log₂n)

Explanation

Each recursive call computes a midpoint and updates a bound using constant arithmetic, then recurses into at most half the remaining interval. There are Θ(log n) calls in the worst case, so total arithmetic operations are Θ(log n), B.

More Searching, Sorting and Hashing questions

All Searching, Sorting and Hashing questions →