title: What is the time complexity of these dependent nested loops?
body: <p>How to calculate time and space complexity for these algorithms?
  I referred many sites but its confusing me. please any one explain me. </p>
  
  <p>1.</p>
  
  <pre><code> for(i=0;i&lt;n;i++)
   {
      for(j=i;j&lt;n;j++)//this for loop is based on previous 'i'
      {
         foo();
      }
   }
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>while(m&lt;n)
  {
      for(i=0;i&lt;n;i++)
      {
           foo();
      }
  }
  </code></pre>
  
  <p>If possible explain me with some more example. Thanks.</p>