Skip to content
Official PYQ · 2003

GATE CS 2003 Q66 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

The cube root of a natural number nn is defined as the largest natural number mm such that (m3≤n)(m^3 \leq n) . The complexity of computing the cube root of nn (nn is represented by binary notation) is 

Choose one option
View worked solution

Answer: C

To find the complexity of computing the cube root of nn, we must analyze the problem in terms of the input size. Let the input nn be represented in binary notation.

1. Input and Output Size

  • The size of the input nn in binary is L=Θ(log⁡n)L = \Theta(\log n) bits.
  • The output m=⌊n1/3⌋m = \lfloor n^{1/3} \rfloor has approximately 13log⁡2n\frac{1}{3} \log_2 n bits. Thus, writing down the output alone requires Ω(log⁡n)\Omega(\log n) time.

2. Algorithm Complexity

We can compute mm using binary search over the range [1,2L/3][1, 2^{L/3}]:

  1. The binary search takes O(L)=O(log⁡n)O(L) = O(\log n) iterations.
  2. In each iteration, we perform basic arithmetic operations (multiplication and comparison) on numbers of size at most LL bits.
  3. Using standard multiplication algorithms, multiplying LL-bit numbers takes O(L2)O(L^2) time (or faster, e.g., O(Llog⁡L)O(L \log L) using advanced methods).

Thus, the total time complexity is polynomial in the input size LL, which is O(Lk)=O((log⁡n)k)O(L^k) = O((\log n)^k) for some constant k>0k > 0 (specifically, k≤3k \le 3).

3. Eliminating Options

  • Since the output size is Ω(log⁡n)\Omega(\log n), any algorithm must take at least linear time in the input size. Therefore, it cannot run in O((log⁡log⁡n)m)O((\log \log n)^m) time for any constant m>0m > 0. This eliminates Option D.
  • Since O((log⁡n)k)O((\log n)^k) is strictly more efficient than O(n0.5)O(n^{0.5}) and O(n)O(n), Options A and B are incorrect.

Hence, the complexity is O((log⁡n)k)O((\log n)^k) for some constant k>0k>0, but not O((log⁡log⁡n)m)O( (\log \log n)^m) for any constant m>0m>0.

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

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