1 votes 1 votes What is the time complexity of the below code? for($k=n^{10};k \geq 5;k=k^{\frac{1}{7}},k=k^2$) { $k=k^5;$ $k=k-10$ } My answer comes to be $O(log_{\frac{7}{10}}log_5(n^{10}))$ Please verify. Algorithms time-complexity algorithms asymptotic-notation + – Ayush Upadhyaya asked Jul 14, 2018 Ayush Upadhyaya 723 views answer comment Share Follow See all 12 Comments See all 12 12 Comments reply Shubham Shukla 6 commented Jul 14, 2018 reply Follow Share yes its correct according to me..! 1 votes 1 votes Mayankprakash commented Jul 14, 2018 reply Follow Share @shubham and @ Ayush Guys can you please post the detail solution as I'm not able to solve this question. Thanks 0 votes 0 votes Shubham Shukla 6 commented Jul 14, 2018 i edited by srestha Jul 16, 2018 reply Follow Share @mayanprakash see $k$ is starting from $n^{10}$ and after one time execution of loop $k$ value is becoming $k=(((k^{5})^{1/7})^{2})= k^{\frac{10}{7}}$ so $(n^{10})^{(\frac{10}{7})^x}=5$ here $x$ will tell how many times will this loop execute until tue $k$ value becomes $5$ so take log on both side $(10/7)^{x} log_{5} n^{10}= 1$ after cross multiply $(7/10)^{x}=log_{5} n^{10}$ now take log again $x= log_ {\frac{7}{10}} log_{5} n^{10}$ its kind of just simplification..you need to do main part here is here how many times $k$ value is after one excn of loop and ignre small effects on $k$ value like here $k=k-10$ wont affect much so ignore it...addition and subtraction wont effect much so you can ignore it, just see for division and multiplication in this type of qsn.. 1 votes 1 votes Ayush Upadhyaya commented Jul 14, 2018 reply Follow Share @Shubham-Please use Latex for more clear formulas. Ref : https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference 0 votes 0 votes Shubham Shukla 6 commented Jul 14, 2018 i edited by Shubham Shukla 6 Jul 14, 2018 reply Follow Share @ayush okk.. hvnt used till now will learn...thanks 0 votes 0 votes Soumya29 commented Jul 16, 2018 reply Follow Share @Shubham @Ayush $2^{nd} $ equation should be $(n^{10})^{(\frac{10}{7})^x}=5 \ or \ ((n^{10})^{\frac{10}{7}})^x=5$ (notice the power $x$). Is it a typo? Which one is correct? 0 votes 0 votes Shubham Shukla 6 commented Jul 16, 2018 i edited by Shubham Shukla 6 Jul 16, 2018 reply Follow Share @soumya ...the thing you wrote first is correct _actually in editing there is some mistake i will correct it..! @srestha please correct it 0 votes 0 votes srestha commented Jul 16, 2018 reply Follow Share @shubham why r u doing equal to 5? 0 votes 0 votes Shubham Shukla 6 commented Jul 16, 2018 reply Follow Share @srestha its because k value cant go below 5 as said in condn...so we are equating to 5 in order to know how mny times our loop will execute before its gets terminated.! 0 votes 0 votes Soumya29 commented Jul 16, 2018 reply Follow Share @Shubham... I am getting $2^{nd}$ one and a different answer :( Each time we are taking $(\frac{10}{7})^{th}$ power of modified $k$ and that last value of k should be $\geq 5$. So shouldn't it be - $((n^{10})^{\frac{10}{7}})^x ?$ 0 votes 0 votes Shubham Shukla 6 commented Jul 16, 2018 reply Follow Share @saumya how? we are doing everytime k^10/7...if you apply two times than it will be k^(10/7^2)...similarly we are applying it for x times so k^((10/7)^x).. 0 votes 0 votes Soumya29 commented Jul 16, 2018 reply Follow Share Ohh yes. Thank you @Shubham :) 0 votes 0 votes Please log in or register to add a comment.