UGC-NET Dec 2012 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0006

Let $T(n)$ be a function defined by $T(n) =1$ and $T(n)=2T (n/2) + \sqrt{n}$, which of the following is true?
  1. A
    $T(n) = O(\sqrt{n})$
  2. B
    $T(n) = O(\log_2 n)$
  3. C
    $T(n) = O(n)$
  4. D
    $T(n) = O(n^2)$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solution\[\boxed{T(n)=aT(n/b)+f(n),\quad f(n)=O(n^{\log_b a-\epsilon})\Rightarrow T(n)=\Theta(n^{\log_b a})}\]Here \(a=2,\ b=2\), so \(n^{\log_2 2}=n\), and \(f(n)=\sqrt n=n^{0.5}=O(n^{1-0.5})\). Case 1 of the master theorem applies:\[T(n)=\Theta(n).\]So \(T(n)=O(n)\). Option D is also an upper bound but not the tight one; A and B are too small.Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com