GATE / CS ARCHIVE

SIMILAR QUESTIONS / ALGORITHMS

Solve square-root argument recurrences

2 questions solved the same way, newest first. Back to Algorithms

How these are solved

Both ask asymptotic order of a square-root recurrence with multiplier 2 and +1 toll, but 2006 explicitly rounds the square-root argument and supplies T(1)=1, whereas 2017 states an unrounded square-root recurrence for n>2 and T(n)=2 for 0<n<=2.

2 marks · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 30, GATE 2017: T(n)=2T(√n)+1 for n>2, and T(n)=2 for 0<n≤2. What is its asymptotic order? A:Θ(log log n). B:Θ(log n). C:Θ(√n). D:Θ(n).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. The argument shrinks by square root, so transform to its logarithm. Put m=log₂n and S(m)=T(2m). Since √(2m)=2m/2, the recurrence becomes S(m)=2S(m/2)+1 with a constant base for m≤1.

2. This is a binary recursion tree with Θ(m) leaves and Θ(m) total nodes. Equivalently, the Master theorem has a=2,b=2 and f(m)=1, giving S(m)=Θ(m).

3. Substituting back gives T(n)=Θ(log n), option B. The recursion depth is only Θ(log log n), but each level branches into twice as many subproblems. Counting depth alone misses the total work.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Square-root divide-and-conquer recurrence

Asymptotic Analysis & Recurrences

Question 51, GATE 2006: For integers n>1, T(n)=2T(⌊√n⌋)+1 and T(1)=1. What is the asymptotic growth?
Options:
(A) Θ(log log n)
(B) Θ(log n)
(C) Θ(√n)
(D) Θ(n)
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. After h repeated floor-square-root steps, the subproblem size is floor(n1/2^h). For n≥2 it first reaches 1 when n<22^h, so h=floor(log₂(log₂ n))+1.

2. The recurrence tree is a full binary tree of height h. Every node contributes one, including the T(1)=1 leaves, so T(n)=2h+1−1. Because log₂ n<2h≤2 log₂ n, this is Θ(log n), option B.

3. Teaching check: The depth is Θ(log log n), but exponentiating that Θ statement alone would not justify Θ(log n). The sharper h=log₂(log₂ n)+O(1) bound controls the number of leaves within constant factors. Floor rounding is included explicitly and ensures termination at the stated base case.

Original paper, page 7