Skip to content
Official PYQ · 1994

GATE CS 1994 Q1.7 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

The recurrence relation that arises in relation with the complexity of binary search is:

Choose one option
View worked solution

Answer: B

In Binary Search, we search for a target element in a sorted array of size nn as follows:

  1. Compare the target element with the middle element of the current search space. This step takes constant time, say kk (where kk is a constant).
  2. If the target is not found at the middle, we discard one half of the array and recursively search in the remaining half of size n2\frac{n}{2}.

Since we only make one recursive call on a subproblem of half the size, the recurrence relation is:

T(n)=T(n2)+kT(n) = T\left(\frac{n}{2}\right) + k

where kk is a constant representing the time taken for the comparison and division steps.

Solving this recurrence using Master's Theorem or iterative substitution yields:

T(n)=O(log⁡n)T(n) = O(\log n)

Thus, Option B is the correct recurrence relation.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions