Question

Consider the recurrence function

T(n)={2T(n)+1,n>22,0<n≤2T(n) = \begin{cases} 2T(\sqrt{n}) + 1, & n > 2 \\ 2, & 0 < n \le 2 \end{cases}

Then T(n)T(n) in terms of Θ\Theta notation is

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2017 answer key

Solution

Apply the substitution method (n=2mn = 2^m) to transform the square-root recurrence into a standard divide-and-conquer recurrence solvable by the Master Theorem.

Given the recurrence T(n)=2T(n)+1T(n) = 2T(\sqrt{n}) + 1 for n>2n > 2.
Let n=2mn = 2^m, so m=log⁡2nm = \log_2 n and n=(2m)1/2=2m/2\sqrt{n} = (2^m)^{1/2} = 2^{m/2}.
Define S(m)=T(2m)=T(n)S(m) = T(2^m) = T(n). Then:

S(m)=2S(m/2)+1S(m) = 2 S(m/2) + 1

Solve S(m)=2S(m/2)+1S(m) = 2S(m/2) + 1 using the Master Theorem:

  • a=2,b=2,f(m)=1=m0a = 2, b = 2, f(m) = 1 = m^0
  • Critical exponent: log⁡ba=log⁡22=1\log_b a = \log_2 2 = 1
  • Since f(m)=O(m1−ϵ)f(m) = O(m^{1 - \epsilon}) for ϵ=1\epsilon = 1, Case 1 of the Master Theorem applies:
S(m)=Θ(m1)=Θ(m)S(m) = \Theta(m^1) = \Theta(m)

Substitute back m=log⁡2nm = \log_2 n:

T(n)=S(m)=Θ(log⁡n)T(n) = S(m) = \Theta(\log n)

This matches option B.

Final answer

B

Common trap

Assuming T(n)=Θ(log⁡log⁡n)T(n) = \Theta(\log \log n) by confusing this recurrence with T(n)=T(n)+1T(n) = T(\sqrt{n}) + 1.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 2
Question
30 of 65, printed as CS Q.30
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.