GeeksforGeeks » Algorithms

Space Complexity?

(3 posts)
  1. learner
    guest
    Posted 1 year ago #

    double foo(int n)
    {
       int i;
       double sum;
       if(n==0)
          retrun 1;
      else
      {
          sum = 0;
          for (i=0; i<n; i++)
                sum+=foo(i);
          retrun sum;
      }
    }

    wht is the space complwexity of thsi???

  2. kartik
    Moderator
    Posted 1 year ago #

    O(n^2) for recursive function calls.

  3. ashish
    guest
    Posted 1 year ago #

    I think space is system stack in recursion so we are not to care about the space in this...


Reply

You must log in to post.

RSS feed for this topic