GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 2.11

Repeated square-root recursion

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

GATE 2002, Q2.11 2 marks · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 2.11, GATE 2002: For procedure A(n), if n≤2 return 1; otherwise return A(⌈√n⌉). Which listed bound best describes its running time?
(A) O(n); (B) O(log n); (C) O(log log n); (D) O(1).
Question 2.11, GATE 2002: For procedure A(n), if n≤2 return 1; otherwise return A(⌈√n⌉). Which listed bound best describes its running time?
(A) O(n); (B) O(log n); (C) O(log log n); (D) O(1).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Take logarithms of the argument shrinkage.

Step 2: Let m=log₂n. Taking a square root approximately halves m, so the recursion needs about log₂m halvings to make m constant. Therefore the number of constant-work calls is Θ(log log n). This count concerns runtime, not the returned value, which is always 1. Arbitrary-precision root computation would require a different per-call cost model.

Conclusion: Ignoring integer rounding initially, after k calls the argument is n1/2^k. It becomes bounded once 2k is of order log n, so the recursion depth is Θ(log log n). Ceiling rounding changes only constants, and the small integer arguments reach the base case. With constant-time root/rounding operations per call, C is the tight listed growth bound, even though looser O(n) and O(log n) bounds are also true.

Original paper, page 4