Dp mcq Time Complexity

predict the complexity of the code:

vector<vector > v(100,vector (100,-1) );
int func(int n,int m)
{
if((n==0)||(m==0))
{
return 0;
}
else
{
if(dp[m][n]!=-1)
{
return dp[m][n];
}
else
{
return func(n-1,m-2)+func(n-2,m-1);
}

  }

}
O(n^2)

O(n logn)

O(2^n)

O(n^3)

Can you explain how 2^n is the answer

the given code is :-

 vector<vector<int > > v(100,vector <int> (100,-1) );
  int func(int n,int m)
  {
      if((n==0)||(m==0))
      {
          return 0;
      }
      else
      {
          if(dp[m][n]!=-1)
          {
              return dp[m][n];
          }
          else
          {
              return func(n-1,m-2)+func(n-2,m-1);
          }

      }


  }

As you can see we are not storing result in dp matrix due to which dp[i][j] is always -1 . so both recursive call will take place even for overlapping cases

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.