3 votes 3 votes Is the answer D ? Algorithms algorithms time-complexity test-series + – Pranjali1894 asked Aug 18, 2017 retagged Jul 18, 2022 by makhdoom ghaya Pranjali1894 626 views answer comment Share Follow See 1 comment See all 1 1 comment reply sachin! commented Aug 19, 2017 reply Follow Share yes , d is correct 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes $a_{n} = \frac{j*(j+1)}{2}$ is the equation being folllowed in inner loop for j. $\implies 2n = j^{2} + j$ $\implies 2n \geq j^{2} \implies j = O(\sqrt{ n})$ Now the while loop is executing $logn$ times giving total complexity = $O(\sqrt{n}logn)$ Aghori answered Aug 19, 2017 selected Aug 19, 2017 by Pranjali1894 Aghori comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments BHAVESH d shah commented Sep 3, 2017 reply Follow Share if j runs from 1 to n. how can be it j∗(j+1)2an=j∗(j+1)2. ? 0 votes 0 votes Aghori commented Sep 3, 2017 reply Follow Share @BHAVESH because the value of j is keep incrementing like. 1,3,6,... 1 votes 1 votes BHAVESH d shah commented Sep 4, 2017 reply Follow Share thanks 0 votes 0 votes Please log in or register to add a comment.