title: time and space complexity
body: <p>I have a doubt related with time and space complexity in following 2 case</p>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <p><strong>Case I:</strong></p>
  
  <p>Recurion: Factorial calculation.</p>
  
  <pre><code>int fact(int n)
  {
      if(n==0)
        return 1;
      else
        return (n*fact(n-1));
  }
  </code></pre>
  
  <p>here how come time complexity become 2*n and space complexity proportional to n.</p>
  
  <p>and </p>
  
  <blockquote>
    <p><strong>Case II:</strong></p>
  </blockquote>
  
  <p>Iterative:-</p>
  
  <pre><code>int fact(int n)
  {
      int i, result = 1;
      if(n==0)
      result = 1;
      else
           {
             for(1=1;i&lt;=n;i++)
                result*=i;
           }
       return (result);
  }
  </code></pre>
  
  <p>Time complexity proportional to n and space complexity is constant.
  This always remain confusing to me.</p>