Please explain the answer

How this question is different question 1 of quiz and please explain the answer?

@shivansh.sm1 hey,1st and kiske beech me difference btana hai?

@rishabhmahajan546 ques1 and 4

@shivansh.sm1 hey please share questions here ,I will tell you.

Q4. DP4
predict the complexity of the code:

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

          }

      }


  }

Q 1. predict the complexity of the code:

  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);
          }

      }


  }

@shivansh.sm1 hi ,pehle question me recursion with memoisation use horhi hai mtlb app recursion ka result dp[][] me store kra rhe ho and reuse kra rhe ho ,dp[n][m]= func(n-1,m-2)+func(n-2,m-1);
return dp[n][m];
dp[n][m] me recursion result store horha hai ,ab wapis same rec call hui to ye stored ans use hoga
whereas in second qstn apka result khi store hi nhi horha ,sirf recursion call horha hai aur bar bar recursion compute hoga ,dp me khi store nhi horha return func(n-1,m-2)+func(n-2,m-1); to isme complexity jada hogi.

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.