Counting Iterations

From the simplifying assumptions, we can reason that the important determinant of runtime in Naive is the number of times the body of the loop is executed.

So, how many iterations does Naive do, as a function of a? Well, we subtract one from it over and over again until we get down to zero. How many times can we do that?

What about Russian? That one's a bit more interesting. There, we divide a by two (and round down) over and over again until we get down to zero. How many times can we do that?


next up previous
Next: Fun With Logarithms Up: ANALYZING RUSSIAN Previous: ANALYZING RUSSIAN