I am trying to figure out why the following is O(n). My doubt is actually on how to figure out the number of iterations of the inner loop without substituting the values.
*Edit: In other words, can anyone show me the derivation using sigma notation?
n = 10
j = 1
for i in range(n):
while j < i:
j *= 2
It is easy to see that the inner while will be executed at most one time per i value, but I am struggling to see more generally how to figure out the last value for j in order to perform the corresponding manipulations in the sums using T(n). Can anyone show the calculation?