I haven't got sufficient knowledge of time complexity, so my question is:
Is there any direct formula to calculate time complexity of an algorithm, example- I have read somewhere that big O of this code is n*log2(n), so can you tell me how they got this expression?
for(i=1;i<=n;i=i*2)
for this loop I am unable to calculate the big O. This loops will make 7 iterations for a value of n=100. How does that help arrive to the given formula?
log2(n)?. Because binary search complexity is the same, and index every time divided by 2. And in this case multiplied by 2.