What is the space complexity of an iterative binary search algorithm implemented without recursion on an array of size n?

Answer and explanation

Correct answer: B. O(1)

  1. Step 1: Analyze memory allocation during iterative binary search.
  2. Step 2: The algorithm uses a fixed number of pointer variables (`low`, `high`, `mid`) and operates directly on the existing array in place without call stack frames, requiring auxiliary space.
Answer
O(1).
Why not the others: space is consumed by recursive binary search due to call stack frames; is auxiliary array copying.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.