Question

Which one of the following correctly determines the solution of the recurrence relation with T(1)=1T(1) = 1?

T(n)=2T(n2)+log⁡nT(n) = 2 T\left(\frac{n}{2}\right) + \log n
Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2014 answer key

Solution

Apply the Master Theorem to solve T(n) = 2T(n/2) + log n.

Given recurrence:

T(n)=2T(n2)+log⁡nT(n) = 2 T\left(\frac{n}{2}\right) + \log n

with T(1)=1T(1) = 1.

  1. Identify Master Theorem Parameters (T(n)=aT(n/b)+f(n)T(n) = a T(n/b) + f(n)):

    • a=2a = 2
    • b=2b = 2
    • f(n)=log⁡nf(n) = \log n
  2. Compute Critical Exponent:

    nlog⁡ba=nlog⁡22=n1=n.n^{\log_b a} = n^{\log_2 2} = n^1 = n.
  3. Compare f(n)f(n) with nlog⁡ban^{\log_b a}:

    • f(n)=log⁡nf(n) = \log n.
    • For any ϵ\epsilon such that 0<ϵ<10 < \epsilon < 1 (for example, ϵ=0.5\epsilon = 0.5):
      log⁡n=O(n1−ϵ)=O(n0.5).\log n = O(n^{1 - \epsilon}) = O(n^{0.5}).
    • Thus, f(n)f(n) is polynomially smaller than nlog⁡ban^{\log_b a}.
  4. By Case 1 of the Master Theorem:

    T(n)=Θ(nlog⁡ba)=Θ(n).T(n) = \Theta(n^{\log_b a}) = \Theta(n).

This matches option A.

Final answer

A

Common trap

Confusing this recurrence with T(n) = 2T(n/2) + n, which yields Theta(n log n).

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

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 2
Question
23 of 65, printed as CS Q.13
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.