title: Find the computational complexity of the following 'for' loop
body: <p>What is the complexity of the following <code>for</code> loop?</p>
  
  <pre><code>n = 0;
  for (i = 1; i &lt;= N; i++)
  {    
      s(i) = sum of the first i coordinates of a
             fixed vector (of dimension N);
  
      % suppose r(i) (for all i) is already computed
      if (r(i) s(i) &gt; r(n) s(n))
          n = i;  
  }
  </code></pre>