I have seen the following pseudocode:
for j=1 to n
m=n
while m>0
//some instructions
m=m/2
I can see that the outer loop is running n times, but when it gets into the while portion it makes a series of m/2. For example, if n=10 I would get roughly that m will take the values of 10,5,2,1 so approximately it will iterate 4 times; when n=100 the values of m would be 100,50,25,12,7,3,1 so approximately 7 iterations. For what I see that would be log n (with base=2) so the final answer would be: n*log n. Am I right?
The problem that I have is how to get the details of the while loop, I can do something like:
n/2=1
n=2 apply log b=2 to both sides, so I will get:
log (base 2) n=log (base 2) 2
log n=1
I have problems with this last part, what would be the correct mathematical deduction of this section?
Thanks