in Algorithms recategorized by
1,225 views
1 vote
1 vote

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. $T(n) = O(\sqrt{n})$
  2. $T(n) = O(\log_2 n)$
  3. $T(n) = O(n)$
  4. $T(n) = O(n^2)$
in Algorithms recategorized by
1.2k views

3 Answers

1 vote
1 vote
Best answer
Apply master theorem  u get O(n) is answer.
selected by
0 votes
0 votes
According to Master's theorem
T(n) =aT(n/b) + nc
a=2, b=2
nc = √n => nc = n1/2 => c=1/2
1. if logba < c, T(n) = Θ(nc),
2. if logba = c, T(n) = Θ(nc log n),
3. if logba > c, T(n) = Θ(nlogba).
Here logba > c, So T(n)= Θ(nlogba)= Θ(n1)= Θ(n)
0 votes
0 votes

Explanation: n(logba) = n which is = n^(1-.5) = O(sqrt n)
then by applying case 1 of master method we get T(n) = Θ(n)

Answer:

Related questions