40 40 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? $T(n) = \Theta(\log n)$ $T(n) = \Theta(\sqrt n)$ $T(n) = \Theta(n)$ $T(n) = \Theta(n \log n)$ Algorithms gateit-2005 algorithms recurrence-relation easy + – Ishrat Jahan 14.6k views answer comment Share Follow Print See all 10 Comments 10 10 Comments reply Show 7 previous comments Kabir5454 commented Oct 17, 2022 reply Follow flag (considering base of $logn$ is $2$) . (1 --logn)-→ total logn terms. (0—logn)→ total logn+1 terms 0 0 replyShare js__ commented Jan 31 reply Follow flag case 1 Master theo 0 0 replyShare Prashant-G commented Jun 3 reply Follow flag Done ✅ 0 0 replyShare Please log in or register to add a comment.
Best answer 53 53 votes 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).$$ Bhagirathi answered Nov 8, 2014 • edited Jun 24, 2018 by Manoja Rajalakshmi A Bhagirathi comment Share Follow See all 8 Comments 8 8 Comments reply Show 5 previous comments Sambhrant Maurya commented Aug 3, 2018 reply Follow flag How to do it using back substitution? 0 0 replyShare Vishal_kumar98 commented Oct 23, 2020 reply Follow flag Master's theorem the Cormen way. Never fails in any case. 0 0 replyShare Pranavpurkar commented Sep 25, 2022 reply Follow flag Sambhrant Maurya 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) 2 2 replyShare Please log in or register to add a comment.
1 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) prashant dubey answered Mar 28, 2019 prashant dubey comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote option c is right abhishekmehta4u answered Mar 28, 2019 abhishekmehta4u comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes let me know if i am doing any mistake. Gangani_Son answered Dec 6, 2018 Gangani_Son comment Share Follow See 1 comment 1 1 comment reply Arqam commented Jan 6, 2019 reply Follow flag Shouldn't it be Math.root(n/2) instead of Math.root(n)/2 ? 1 1 replyShare Please log in or register to add a comment.
0 0 votes T(n)=O(n) jay__sadhu answered Oct 17, 2022 jay__sadhu comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Following is the solution of this question using Master's Method: amaanshaikh_27 answered May 20 amaanshaikh_27 comment Share Follow 0 reply Please log in or register to add a comment.