हिंदी

The following function int solve() is a part of some class. Assume ‘m’ and ‘n’ are positive integers. Answer the question given below with dry run/working. int solve(int m, int n) { int k=1; if(m<0) - Computer Science (Theory)

Advertisements
Advertisements

प्रश्न

The following function int solve() is a part of some class. Assume ‘m’ and ‘n’ are positive integers. Answer the question given below with dry run/working.

int solve(int m, int n)
  {
    int k=1;
    if(m<0)
      return −k;
    else if(m==0)
      return m;
    else
      return k+(solve(m−n, n+2));
}

What is the function solve() performing apart from recursion?

अति संक्षिप्त उत्तर
Advertisements

उत्तर

The function counts steps while gradually decreasing m as n increases, with the exception of recursion.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2024-2025 (March) Official Board

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×