0 votes 0 votes i = n; While(i > 0) { i= i/2; } Algorithms time-complexity algorithms + – aka 53 asked Nov 22, 2017 aka 53 270 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes complexity is O($\log _{2}n$) simply consider cases as n= 2$^{2}$ , output=2 n = 2$^{3}$ , output=3 n = 2$^{k}$ , output=k = log$_{2}$2$^{k}$ solving in this way is easier thus it is O($\log _{2}n$) kirti_k answered Nov 22, 2017 selected Nov 22, 2017 by aka 53 kirti_k comment Share Follow See all 0 reply Please log in or register to add a comment.