The cube root of a natural number n is defined as the largest natural number m such that m^3 <= n. The complexity of computing the cube root of n (n is represented by b bits in binary notation) is: A. O(b) but not O(1) B. O(b^(1/2)) but not O(1) for any constant k > 0 C. O(b^k) for some constant k > 0.5, but not O(b^(1/2)) for any constant k D. O(2^b) but not O(b^k) for any constant k

GATE 2003 · Algorithms · Time Complexity · medium

Answer: The complexity is O(b) but not O(1). Answer: A.

  1. Identify the search space: Since n < 2^b, we have n^(1/3) < 2^(b/3). Binary search over [0, 2^(b/3)] requires at most log_2(2^(b/3)) = b/3 iterations.
  2. Determine total complexity: Each binary search iteration does O(1) comparisons (treating arithmetic as O(1)). Total complexity = O(b/3) = O(b). This is not O(1) since we cannot determine the cube root without examining any bits.