in Algorithms edited by
7,390 views
27 votes
27 votes

Let $T(n)$ be a function defined by the recurrence

$T(n) = 2T(n/2) + \sqrt n$ for $n \geq 2$ and
$T(1) = 1$

Which of the following statements is TRUE?

  1. $T(n) = \Theta(\log n)$
  2. $T(n) = \Theta(\sqrt n)$
  3. $T(n) = \Theta(n)$
  4. $T(n) = \Theta(n \log n)$
in Algorithms edited by
7.4k views

4 Comments

@piyushwm Your recursion tree is wrong. Check once again.
0
0

@gatecse @Abhrajyoti00 @Kabir5454

Somebody explain How( see comment of @piyushwm)

$\sqrt{2}^{logn} = \sqrt{n}$

and

In the gp , how you came to know that number of terms = logn not logn +1

0
0

(considering base of $logn$ is $2$) .

(1 --logn)-→ total logn terms.

(0—logn)→ total logn+1 terms 

 

0
0

5 Answers

36 votes
36 votes
Best answer

Option $C$ is the answer. It can be done by Master's theorem.

$n^{\log_b a} = n^{\log_2 2} = n$.

$f(n) = \sqrt n = n^{\frac{1}{2}}$.

So, $f(n) = O\left(n^{\log_b a -\epsilon}\right)$ is true for any real $\epsilon$, $0 < \epsilon < \frac{1}{2}$. Hence Master theorem Case 1 satisfied,
$$T(n) = \Theta\left(n^{\log_b a}\right) = \Theta (n).$$

edited by

4 Comments

How to do it using back substitution?
0
0
Master's theorem the Cormen way. Never fails in any case.
1
1

it will form a GP series like

n*(1+1/√2  +  1/√4 +1/√8 +1/√16 + ………………..+ 1/√n )

here the series is decreasing GP series thus 

T(n) = ⊖(n)

0
0
1 vote
1 vote
Answer is C it can also be solved by master theorem. by case 1(a>=b^k)

T(n)= aT(n/b)+n^k

Here a = 2 b=2 and k =1/2

so a>= b^k

T(n)=Θ (n^logba)

hence T(n)=Θ(n)
0 votes
0 votes

 

let me know if i am doing any mistake.

1 comment

Shouldn't it be Math.root(n/2) instead of Math.root(n)/2 ?
1
1
0 votes
0 votes

option c is right

Answer:

Related questions