GATE / CS ARCHIVE

GATE CSE 2003 / QUESTION 66

Bit complexity of integer cube root

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 2003 paper

GATE 2003, Q66 2 marks · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 66, GATE 2003: The integer cube root of a natural number n is the largest natural m with m³≤n. The input n is represented in binary. Which describes its computation complexity?
A. O(n), but not O(n^0.5)
B. O(n^0.5), but not O((log n)^k) for any constant k>0
C. O((log n)^k) for some constant k>0, but not O((log log n)^m) for any constant m>0
D. O((log log n)^k) for some constant k>0.5, but not O((log log n)^0.5)
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The input length is b=floor(log2 n)+1; complexity in n and in the bit length b must not be confused.
2. Binary search the integer interval [0,n], retaining the largest tested m with m³≤n. Halving the interval takes O(log n)=O(b) iterations.
3. Using schoolbook arithmetic, a multiplication of O(b)-bit numbers costs O(b²); two multiplications form m³. Hence this explicit algorithm costs O(b³), polynomial in log n.
4. The output cube root has about b/3 bits, so even writing it costs Ω(b), which dominates every fixed power of log b. Thus a polynomial in log log n cannot suffice in the bit model, and C follows.

Solution: Let b be the number of input bits, so b=Theta(log n). Binary search for the largest m with m³≤n needs O(b) comparisons. Schoolbook multiplication computes a b-bit cube in O(b²) bit operations, giving an explicit O(b³) algorithm. The answer itself has Theta(b) bits for growing n, so writing it already requires Omega(b) bit operations. Thus the problem is polynomial in log n, but not polynomial in log log n, option C. This is a bit-complexity statement, not a unit-cost model for arbitrarily large integers.

Original paper, page 9