To express the loop in terms of a summation, we need to consider what the loop is doing. The loop progresses by doubling ( m ) each time, starting from ( m = 1 ) and continuing while ( m < n ). If we represent the work done in each iteration as some function ( f(m) ), the total work done can be expressed as a summation.
However, since the loop condition involves doubling ( m ) until it is not less than ( n ), we can express the iterations in terms of powers of 2. Let's focus on the number of iterations instead and how to express the doubling process as a summation.
At each step ( k ), ( m ) equals ( 2^k ), and the loop continues until ( 2^k ) is not less than ( n ). Therefore, the number of iterations ( k ) is determined by:
[ 2^k \geq n ]
To find the maximum ( k ), equate and solve:
[ k \leq \log_2(n) ]
Since the bound is strict, the loop executes for integer values ( k ) starting from 0 up to ( \lfloor \log_2(n) \rfloor ). Thus, we can consider ( n ) effectively as the upper bound for the last completed operation in terms of powers of 2.
The summation can be structured as:
[
\sum_{m=1, , \text{doubling}}^{n} 1
]
Considering the actual number of doubling steps, this sums over each power of 2:
[
\sum_{k=0}^{\lfloor \log_2(n) \rfloor} 1
]
This summation simply counts the iterations that the loop runs, which is ( \lfloor \log_2(n) \rfloor + 1 ). This demonstrates again why the time complexity is ( O(\log n) ).
In conclusion, if you express the series of operations by considering the doubling of the loop until it reaches ( n ), the result is equivalent to computing:
[
\sum_{k=0}^{\lfloor \log_2(n) \rfloor} 1 = \lfloor \log_2(n) \rfloor + 1
]
Thus, the complexity remains ( O(\log n) ).