Is this algorithm quadratic or linear?
<p>I have the following algorithm:</p>

<pre><code>s=0
for j=1 to n
    k=n
    while k&gt;0
        s++
        k=(int)k/2
    endwhile
endfor
</code></pre>

<p>For what I have analyzed when:</p>

<pre><code>j=1 the while loop executes 1 time
j=2 the while loop executes 2 times
j=3 ...                     2 times
j=4 ...                     3 times
j=5 ...                     3 times
j=6 ...                     3 times
j=7 ...                     3 times
j=8 ...                     4 times
</code></pre>

<p>So I will have a summation of (n/2)*n of the outer loop, so will this be O(n^2)?      </p>